Skip to content

[Bug]: doNotFake option for useFakeTimers is ignored when it contains all available options #15374

Open

Description

Version

29.7.0

Steps to reproduce

Steps:

  1. Clone my repo at https://github.com/ensconced/jest-do-not-fake-bug
  2. npm install
  3. npm test

Expected behavior

Both tests should pass.

Actual behavior

One of the tests times out.

Additional context

It seems like when you include all the available options in doNotFake, like this:

  jest.useFakeTimers({
    doNotFake: [
      "Date",
      "hrtime",
      "nextTick",
      "performance",
      "queueMicrotask",
      "requestAnimationFrame",
      "cancelAnimationFrame",
      "requestIdleCallback",
      "cancelIdleCallback",
      "setImmediate",
      "clearImmediate",
      "setInterval",
      "clearInterval",
      "setTimeout",
      "clearTimeout",
    ],
  });

...it's equivalent to doing this:

  jest.useFakeTimers();

...whereas it should be equivalent to not faking timers at all.

Environment

System:
    OS: macOS 14.4
    CPU: (8) arm64 Apple M1 Pro
  Binaries:
    Node: 20.9.0 - ~/.local/state/fnm_multishells/83672_1731248039013/bin/node
    npm: 10.1.0 - ~/.local/state/fnm_multishells/83672_1731248039013/bin/npm
    pnpm: 9.9.0 - /opt/homebrew/bin/pnpm
  npmPackages:
    jest: ^29.7.0 => 29.7.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions