Packages

@jest/fake-timers

30.5.2 · 18 Sep 2026MIT78.4M / weekRepositoryHomepagenpmAtom feed

Your version

27.0.0

major25 May 2021Where it was published

27.5.1 is the newest release of 27.x.

In short

47 breaking36 new4 faster36 fixed10 internal

  • breaking

    jest-circus: Fail tests when multiple done() calls are made

  • breaking

    jest-circus, jest-jasmine2: Fail the test instead of just warning when describe returns a value

  • breaking

    jest-config: Default to Node testing environment instead of browser (JSDOM)

  • breaking

    jest-config: Use jest-circus as default test runner

  • breaking

    jest-config, jest-runtime: Use "modern" implementation as default for fake timers (#10874 & #11197)

  • breaking

    [jest-config, jest-haste-map, jest-resolve, jest-runner, jest-runtime, jest-test-sequencer, jest-transform, jest-types] Add custom HasteMap class implementation config option

  • breaking

    jest-repl, jest-runner: Run transforms over environment

  • breaking

    jest-runner: Set exit code to 1 if test logs after teardown

Release note

Blog post

Features

  • babel-jest: Add async transformation

  • jest-changed-files: Use '--' to separate paths from revisions

  • breaking

    jest-circus: Fail tests when multiple done() calls are made

  • breaking

    jest-circus, jest-jasmine2: Fail the test instead of just warning when describe returns a value

  • breaking

    jest-config: Default to Node testing environment instead of browser (JSDOM)

  • breaking

    jest-config: Use jest-circus as default test runner

  • jest-config: Add support for preset written in ESM

  • jest-config, jest-runtime: Support ESM for files other than .js and .mjs

  • breaking

    jest-config, jest-runtime: Use "modern" implementation as default for fake timers (#10874 & #11197)

  • [jest-config Allow passing forceNodeFilesystemAPI through to jest-haste-map

  • breaking

    [jest-config, jest-haste-map, jest-resolve, jest-runner, jest-runtime, jest-test-sequencer, jest-transform, jest-types] Add custom HasteMap class implementation config option

  • jest-core: Make TestWatcher extend emittery

  • jest-core: Run failed tests interactively the same way we do with snapshots

  • jest-core: More TestSequencer methods can be async

  • jest-core: Add support for testSequencer written in ESM

  • jest-core: Add support for globalSetup and globalTeardown written in ESM

  • jest-core: Add support for watchPlugins written in ESM

  • jest-core: Add support for runner written in ESM

  • jest-core: Add support for reporters written in ESM

  • jest-each: Add support for interpolation with object properties

  • jest-environment-node: Add AbortController to globals

  • @jest/fake-timers: Update to @sinonjs/fake-timers to v7

  • jest-haste-map: Handle injected scm clocks

  • jest-haste-map: Add enableSymlinks configuration option to follow symlinks for test files

  • breaking

    jest-repl, jest-runner: Run transforms over environment

  • jest-repl: Add support for testEnvironment written in ESM

  • breaking

    jest-runner: Set exit code to 1 if test logs after teardown

  • breaking

    jest-runner: Run transforms over runnner

  • breaking

    jest-runner: Run transforms over testRunnner

  • jest-runner: Possibility to use ESM for test environment (11033)

  • jest-runner: Add support for testRunner written in ESM

  • jest-runtime: Detect reexports from CJS as named exports in ESM

  • jest-runtime: Support for async code transformations (#11191 & #11220)

  • jest-reporters: Add static filepath property to all reporters

  • breaking

    jest-snapshot: Make prettier optional for inline snapshots - fall back to string replacement (#7792 & #11192)

  • breaking

    jest-snapshot: Run transforms over snapshotResolver

  • jest-transform: Pass config options defined in Jest's config to transformer's process and getCacheKey functions

  • jest-transform: Add support for transformers written in ESM

  • breaking

    jest-transform: Do not export ScriptTransformer class, instead export the async function createScriptTransformer

  • jest-transform: Async code transformations

  • jest-transform: Support transpiled transformers

  • breaking

    jest-transform: requireAndTranspileModule always return a Promise, and the third parameter type is changed to RequireAndTranspileModuleOptions which accept applyInteropRequireDefault option

  • breaking

    jest-transform: createTranspilingRequire return function which return a Promise now

  • jest-util: Add requireOrImportModule for importing CJS or ESM

  • jest-util: Add applyInteropRequireDefault option on requireOrImportModule

  • jest-watcher: Added support for clearing the line when <C-u> is pressed in a watch mode pattern prompt

  • jest-worker: Add support for custom task queues and adds a PriorityQueue implementation.

  • jest-worker: Add in-order scheduling policy to jest worker (10902)

  • pretty-format: Better print for sparse arrays (11326)

  • pretty-print: Add option printBasicPrototype which determines whether or not the prototype should be printed for raw objects or arrays

Fixes

  • babel-plugin-jest-hoist: Add __dirname and __filename to whitelisted globals

  • breaking

    expect: Revise expect.not.objectContaining() to be the inverse of expect.objectContaining(), as documented.

  • breaking

    expect: Make toContain more strict with the received type (#10119 & #10929)

  • breaking

    expect: matcherResult on JestAssertionError are now strings rather than functions

  • jest-circus: Fixed the issue of beforeAll & afterAll hooks getting executed even if it is inside a skipped describe block #10451

  • jest-circus: Fix testLocation on Windows when using test.each

  • jest-cli: Use testFailureExitCode when bailing from a failed test

  • jest-cli: Print custom error if error thrown from global hooks is not an error already

  • jest-cli: Allow running multiple "projects" from programmatic API

  • jest-cli: Fix missing collectCoverage after init

  • jest-cli, jest-config, jest-types: Move all default values into jest-config

  • breaking

    jest-config: Change default file extension order by moving json behind ts and tsx (10572)

  • jest-console: console.dir now respects the second argument correctly

  • jest-core: Don't report PerformanceObserver as open handle

  • jest-core: Use WeakRef to hold timers when detecting open handles

  • jest-core: Correctly detect open handles that were created in test functions using done callbacks

  • jest-core: Do not collect RANDOMBYTESREQUEST as open handles

  • jest-core: Wait briefly for open handles to close before flagging them when using --detectOpenHandles

  • breaking

    jest-diff: Use only named exports

  • breaking

    jest-each: Ignore excess words in headings

  • jest-each: Support array index with template strings

  • jest-each: Interpolate %% correctly

  • jest-each: Fix wrong interpolation when the value of array contains multiple %

  • breaking

    jest-environment: Drop support for runScript for test environments

  • jest-environment-jsdom: Use inner realm’s ArrayBuffer constructor

  • breaking

    jest-environment-jsdom: Remove Node globals setImmediate and clearImmediate #11222

  • breaking

    jest-get-type: Convert to ES Module

  • breaking

    jest-globals: Disallow return values other than a Promise from hooks and tests

  • breaking

    jest-globals: Disallow mixing a done callback and returning a Promise from hooks and tests

  • jest-haste-map: Vendor NodeWatcher from sane

  • jest-jasmine2: Fixed the issue of beforeAll & afterAll hooks getting executed even if it is inside a skipped describe block when it has child tests marked as either only or todo #10451

  • jest-jasmine2: Fixed the issues of child tests marked with only or todo getting executed even if it is inside a skipped parent describe block #10451

  • jest-jasmine2: Wrap all test functions so they open handles that were created in test functions using done callbacks can be detected

  • jest-reporter: Handle empty files when reporting code coverage with V8

  • jest-resolve: Replace read-pkg-up with escalade package

  • jest-resolve: Disable jest-pnp-resolver for Yarn 2

  • breaking

    jest-runtime: Do not inject global variable into module wrapper

  • breaking

    jest-runtime: Remove long-deprecated jest.addMatchers, jest.resetModuleRegistry, and jest.runTimersToTime

  • jest-runtime: Fix stack overflow and promise deadlock when importing mutual dependant ES module

  • jest-runtime: Prevent global module registry from leaking into isolateModules registry

  • jest-runtime: Refactor to prevent race condition when linking and evaluating ES Modules

  • jest-runtime: Throw correct error when attempting to load ESM via require

  • jest-runtime: Do not cache modules that throw during evaluation

  • jest-transform: Show enhanced SyntaxError message for all SyntaxErrors

  • breaking

    jest-transform: Refactor API to pass an options bag around rather than multiple boolean options

  • breaking

    jest-transform: Refactor API of transformers to pass an options bag rather than separate config and other options

  • jest-types: Fix Config.ts projects types

  • jest-util: Replace micromatch with picomatch to fix issues with negated globs

  • jest-validate: Use en-US locale to avoid case conversion problems while validating CLI options on machines with some certain locales(e.g. Turkish) set as default locale.

  • breaking

    jest-worker: Use named exports

  • jest-worker: Do not swallow errors during serialization

  • jest-worker: Handle ERR_IPC_CHANNEL_CLOSED errors properly

  • breaking

    pretty-format: Convert to ES Modules

  • pretty-format: Only call hasAttribute if it's a function

  • pretty-format: Handle jsdom attributes properly

  • pretty-format: Import pretty-format using named imports

Chore & Maintenance

  • breaking

    *: Only support Node LTS releases and Node 15

  • breaking

    *: Add exports field to all package.jsons

  • breaking

    *: Remove deprecated mapCoverage

  • breaking

    babel-jest: Migrate to ESM

  • breaking

    jest, jest-core: Replace TestScheduler export with createTestScheduler

  • breaking

    jest-config: Remove enabledTestsMap config, use filter instead

  • breaking

    jest-console: Move root into config and take GlobalConfig as mandatory parameter for getConsoleOutput

  • breaking

    jest-haste-map: Migrate to ESM

  • breaking

    jest-haste-map: Remove support for deprecated option ignorePattern as function

  • breaking

    jest-jasmine2: Migrate to ESM

  • breaking

    jest-jasmine2: Remove unused options argument from Env constructor

  • breaking

    jest-repl, jest-runtime: Move the jest-runtime CLI into jest-repl (#10016 & #10925)

  • breaking

    jest-resolve: Migrate to ESM

  • breaking

    jest-resolve-dependencies: Migrate to ESM

  • breaking

    jest-mock: Migrate to ESM

  • breaking

    jest-reporters: Make node-notifier a peer dependency

  • breaking

    jest-resolve, jest-runtime: Use Maps instead of objects for all cached resources

  • breaking

    jest-runner: Migrate to ESM

  • breaking

    jest-runtime: Remove deprecated and unused getSourceMapInfo from Runtime

  • breaking

    jest-transformer: Remove unused isCoreModule option

  • breaking

    jest-validate: Remove recursiveBlacklist option in favor of previously introduced recursiveDenylist

Performance

  • jest-resolve: Cache reading and parsing of package.jsons

  • jest-runtime, jest-transform: Share cacheFS between runtime and transformer

  • jest-runtime: Load chalk only once per worker

  • jest-worker: Fix memory leak of previous task arguments while no new task is scheduled