Repository navigation
feat(jest-runtime): automock ESM, sandbox the loader escape hatches, and match Node's graph-error ordering - #16391
Conversation
β¦ factory A factory-less ESM mock decision - automock: true, or a manual __mocks__ file - crashed with "Attempting to import a mock without a factory": an invariant on the sync graph walker, a plain throw on the legacy async path. Since the require(esm) root started consulting mock decisions, plain require() of an ESM file under automock crashed the same way, where it previously loaded the real module for metadata. Mirror the CJS _requireMockWithId branches in the ESM loader: load a sibling __mocks__ file as the mock module, otherwise load the real module in scratch registries and generate an automock from its namespace. CJS targets of an ESM mock decision load through the mock-free Runtime.requireModule seam and get the usual synthetic wrapper. The legacy importMock delegates to the same builder on capable Nodes so dynamic import() serves identical mock instances. The CJS automock path routes ESM targets through requireModule so the ESM-side generation answers - running the CJS generateMock against them recursed into the ESM mock consult and automocked the fresh mock a second time, off its own placeholder metadata.
The sandbox process is a copy, so getBuiltinModule was the host function
by reference. It handed back the host process - Node guarantees
process.getBuiltinModule('process') === process, which held false inside
a test - and the host node:module, whose createRequire loads files
outside Jest's registry, mocks and transforms. Dispatch through the same
provider a require() of a core module uses; unknown names return
undefined, as in Node.
β¦ the sandbox Both statics were copied off the host Module class, so a hook registered inside a test attached to the loader running Jest itself: it observed Jest's internal requires, never saw the sandboxed require/import it was meant to customize (those go through jest-resolve), and stayed registered for every later test file in the worker. Throw an actionable error instead, alongside the existing syncBuiltinESMExports stub.
Building a CJS dep's synthetic executes the CJS body (the export-name merge needs the runtime exports object), and the walker built it the moment the specifier resolved. A graph with an unresolvable sibling or an invalid import attribute therefore ran side effects Node's loader never runs - Node resolves and validates the whole graph before executing anything. Defer the builds until the resolution worklist drains: attribute and resolution errors now throw with nothing executed, and a build whose file turns out to hold unmarked ESM syntax re-enters the worklist. The bodies still run in discovery order ahead of the ESM bodies rather than interleaved in Node's evaluation post-order - the export-name snapshot forces execution before linking; documented in the divergences list. Resolution errors also stopped bailing sync-preferred walks to the legacy path: both walker entries gate on canResolveSync(), so the sync resolver's failure is authoritative, and the legacy retry executed already-resolved CJS deps before rediscovering the same error.
Node satisfies a source-phase request ('import source' /
'import.source()', used for WebAssembly) by attaching the compiled
WebAssembly.Module to the target via the internal
ModuleWrap#setModuleSourceObject. node:vm exposes no equivalent, so the
phase cannot be implemented on the vm-based loader; V8 failed at
instantiate() with a bare "Source phase import object is not defined"
SyntaxError pointing at Jest internals.
Detect the phase - on moduleRequests in the sync walker and the legacy
loader, and via the dynamic-import callback's phase argument for
import.source() from ESM and CJS alike - and throw
ERR_SOURCE_PHASE_NOT_DEFINED explaining the vm gap.
Node's import.meta.resolve is resolution-only: a missing relative target returns its URL unchecked, and an unresolvable bare specifier throws ERR_MODULE_NOT_FOUND. Jest answers with the full jest-resolve pipeline instead - that is the API's value inside a test - so a missing file throws MODULE_NOT_FOUND. State that in place so the divergence reads as chosen, not missed.
β¦rom EsmLoader Both blocks are self-contained: the WHATWG data URL decoding moves to dataUri.ts, and import-attribute validation moves to importAttributes.ts as ImportAttributeValidator. The validator's warned-pairs set was module-scoped, deduplicating the JSON-without-attribute deprecation warning across every Runtime in a worker - the second and later test files never saw it. Instance state on the per-Runtime validator restores the warning per test file.
β Deploy Preview for jestjs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
There was a problem hiding this comment.
Pull request overview
Improves jest-runtime ESM parity with Node by supporting automocks, sandboxing loader APIs, preserving graph-error ordering, and clarifying unsupported source-phase imports.
Changes:
- Adds ESM automock and manual mock generation.
- Sandboxes builtin-module access and rejects unsafe loader hooks.
- Defers CJS execution and adds source-phase/import-attribute handling.
Reviewed changes
Copilot reviewed 27 out of 27 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
CHANGELOG.md |
Records runtime changes. |
docs/ECMAScriptModules.md |
Documents ESM behavior and divergences. |
eslint.config.mjs |
Excludes unsupported source-phase syntax. |
packages/jest-runtime/src/index.ts |
Wires ESM loading and sandbox builtins. |
packages/jest-runtime/src/internals/EsmLoader.ts |
Implements primary ESM behavior changes. |
packages/jest-runtime/src/internals/ModuleExecutor.ts |
Propagates dynamic import phases. |
packages/jest-runtime/src/internals/MockState.ts |
Supports metadata rollback. |
packages/jest-runtime/src/internals/cjsRequire.ts |
Rejects host loader hooks. |
packages/jest-runtime/src/internals/dataUri.ts |
Extracts data URI parsing. |
packages/jest-runtime/src/internals/importAttributes.ts |
Extracts instance-scoped validation. |
packages/jest-runtime/src/internals/__tests__/EsmLoader.test.ts |
Updates loader test setup. |
packages/jest-runtime/src/internals/__tests__/cjsRequire.test.ts |
Tests hook rejection. |
packages/jest-runtime/src/internals/__tests__/importAttributes.test.ts |
Tests attribute validation. |
packages/jest-runtime/src/__tests__/runtime_environment.test.js |
Tests sandbox builtin access. |
packages/jest-runtime/src/__tests__/runtime_esm_sync_graph.test.ts |
Tests automock, graph errors, and phases. |
packages/jest-runtime/src/__tests__/test_esm_sync_graph_root/automock-cjs-dep.cjs |
Provides CJS automock fixture. |
packages/jest-runtime/src/__tests__/test_esm_sync_graph_root/automock-dep.mjs |
Provides ESM automock fixture. |
packages/jest-runtime/src/__tests__/test_esm_sync_graph_root/automock-dynamic.mjs |
Provides dynamic import fixture. |
packages/jest-runtime/src/__tests__/test_esm_sync_graph_root/automock-manual-dep.mjs |
Provides real manual-mock target. |
packages/jest-runtime/src/__tests__/test_esm_sync_graph_root/__mocks__/automock-manual-dep.mjs |
Provides manual ESM mock. |
packages/jest-runtime/src/__tests__/test_esm_sync_graph_root/cjs-sideeffect.cjs |
Tracks premature CJS execution. |
packages/jest-runtime/src/__tests__/test_esm_sync_graph_root/dynamic-source-phase.mjs |
Exercises import.source(). |
packages/jest-runtime/src/__tests__/test_esm_sync_graph_root/import-automock-cjs-dep.mjs |
Imports an automocked CJS dependency. |
packages/jest-runtime/src/__tests__/test_esm_sync_graph_root/import-automock-dep.mjs |
Imports an automocked ESM dependency. |
packages/jest-runtime/src/__tests__/test_esm_sync_graph_root/import-cjs-bad-attribute.mjs |
Tests attribute-error ordering. |
packages/jest-runtime/src/__tests__/test_esm_sync_graph_root/import-cjs-then-missing.mjs |
Tests resolution-error ordering. |
packages/jest-runtime/src/__tests__/test_esm_sync_graph_root/import-source-phase.mjs |
Exercises static source imports. |
π‘ Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
babel-jest
babel-plugin-jest-hoist
babel-preset-jest
create-jest
@jest/diff-sequences
expect
@jest/expect-utils
jest
jest-changed-files
jest-circus
jest-cli
jest-config
@jest/console
@jest/core
@jest/create-cache-key-function
jest-diff
jest-docblock
jest-each
@jest/environment
jest-environment-jsdom
@jest/environment-jsdom-abstract
jest-environment-node
@jest/expect
@jest/fake-timers
@jest/get-type
@jest/globals
jest-haste-map
jest-jasmine2
jest-leak-detector
jest-matcher-utils
jest-message-util
jest-mock
@jest/pattern
jest-phabricator
jest-regex-util
@jest/reporters
jest-resolve
jest-resolve-dependencies
jest-runner
jest-runtime
@jest/schemas
jest-snapshot
@jest/snapshot-utils
@jest/source-map
@jest/test-result
@jest/test-sequencer
@jest/transform
@jest/types
jest-util
jest-validate
jest-watcher
jest-worker
pretty-format
commit: |
A pending file holding unmarked ESM syntax was only discovered when its build threw CjsParseError - after earlier pendings had already executed, so a resolution failure in the re-entered subgraph could no longer stop their side effects. Classify each pending first, by probing hasEsmSyntax on the transformed source - the discriminator every CjsParseError producer gates on - and execute confirmed CJS bodies only once the worklist and the pending queue are both empty. Files the probe cannot classify (incomplete syntax both parsers reject) confirm as CJS, so the build still surfaces the canonical compile error, and a build-time CjsParseError the lexer tolerated still falls back to the worklist.
A top-level-await root forces the legacy loader, exercising its moduleRequests scan; a CJS module calling import.source() exercises the phase argument threaded through compileFunction's dynamic-import callback. Also document the factory-less mock decisions the legacy importMock still cannot serve as a known hole.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 31 out of 31 changed files in this pull request and generated no new comments.
Suppressed comments (5)
packages/jest-runtime/src/internals/EsmLoader.ts:1075
- This eagerly builds a factory-less automock while the graph is still resolving, and automock generation executes the real target to collect metadata. With
automock: true, a graph that imports a side-effecting CJS module before a missing sibling will therefore run that CJS body before the later resolution error; an invalid attribute is also validated only after this call. Defer mock generation until all requests have resolved and their attributes have been validated, just as the new pending-CJS path does.
const mocked = this.importMockSync(
referencingIdentifier,
specifierPath,
moduleID,
context,
packages/jest-runtime/src/index.ts:480
- A normal CommonJS
require()entersrequireModuleOrMock()and_requireMockWithId(). When a sibling manual mock exists, the branch at line 463 loads that.mjsfile directly throughCjsLoader.loadModule, so this new ESM delegation is never reached and the manual mock is compiled as CommonJS. The added test callsruntime.requireModule()directly and therefore misses the user-facing path. Route ESM manual mocks through the ESM loader as well, and coverrequireModuleOrMock()so documentedrequire()support works.
mockRegistry.set(moduleID, this._generateMockForTarget(from, moduleName));
CHANGELOG.md:14
- The release note promises this for ESM generally, but the new fallback explicitly still throws when the target graph requires async evaluation (for example, top-level await) on Node 24.9+. Qualify the entry to synchronously evaluable ESM graphs unless the async generated-mock path is implemented.
- `[jest-runtime]` Apply automocking and manual `__mocks__` files to ESM on Node 24.9+ - static imports, dynamic `import()` and `require()` of an ESM file now generate an automock from the real module's namespace instead of failing with "Attempting to import a mock without a factory" ([#16391](https://github.com/jestjs/jest/pull/16391))
packages/jest-runtime/src/internals/tests/EsmLoader.test.ts:88
- Avoid the untyped
anycast for this new mock; it discards therequireModulesignature and can hide incorrect calls in these loader tests. Instantiatejest.fnwith the function type, matching the repository's typed-mock requirement.
requireModule: jest.fn() as any,
docs/ECMAScriptModules.md:85
- This statement is broader than the implementation:
importMock()still throwsAttempting to import a mock without a factorywhen the real module graph requires async evaluation, including top-level await (EsmLoader.ts:2072-2078), even on Node 24.9+. Either implement the async generated-mock path or document that support is limited to synchronously evaluable ESM graphs.
On Node 24.9+, [automocking](Configuration.md#automock-boolean) and manual `__mocks__` files also apply to ESM: an automock is generated from the real module's namespace, and a sibling `__mocks__` file replaces it, for static imports, dynamic `import()` and `require()` alike.
Two holes in the user-facing require() path, which reaches mocks through
requireModuleOrMock and _requireMockWithId rather than the ESM loader:
- A sibling __mocks__/*.mjs manual mock was executed as CommonJS through
CjsLoader.loadModule, crashing with a CjsParseError when no transform
rewrites it.
- jest.mock('./esm.mjs') without a factory routed to requireModule,
whose ESM decision consult knows nothing about CJS registrations and
returned the real module.
Route ESM targets to a forced-mock entry on the ESM loader that skips
the decision re-consult: it loads a manual mock in its own format and
generates the automock from the real namespace, sharing the instance
with imports.
A factory-less mock decision generated its mock during resolution, and generation executes the real module to collect metadata - so with automock: true a side-effecting module ran before a later sibling's resolution or import-attribute error, the ordering the pending-CJS deferral just closed. Queue factory-less decisions alongside the pending CJS builds; the module ID is the cache key, so dependency edges reference the mock before it is generated. Registered factories and already-instantiated mocks keep their eager timing.
β¦stubs The changelog and docs promised automocking for ESM generally; the generated-mock path only serves synchronously evaluable graphs, so top-level await and async-only resolvers or transformers still throw. Say so. Also give the requireModule/requireModuleOrMock test stubs their real signatures instead of an any cast.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 33 out of 33 changed files in this pull request and generated 2 comments.
Suppressed comments (2)
Previously missed (1) β in code that hasn't changed since the last review.
packages/jest-runtime/src/index.ts:517
Runtimeis a public subclassing extension point, but this callback bypasses an overriddenrequireModuleand calls the internal provider directly. Consequentlyprocess.getBuiltinModule()behaves differently fromrequire()for consumers that customize module loading through the documented override seam. Dispatch the builtin throughthis.requireModule(this._testPath, id)instead.
sandboxProcess.getBuiltinModule = (id: string) =>
nativeModule.isBuiltin(id) ? this.coreModule.require(id) : undefined;
packages/jest-runtime/src/internals/EsmLoader.ts:1173
- A configured resolver may legitimately export distinct
syncandasynchooks;canResolveSync()only confirms thatsyncexists, whileresolveModuleAsyncexplicitly prefers the separateasynchook. Making the sync failure authoritative therefore regresses dynamic imports whose sync hook cannot resolve a specifier but whose async hook can. Preserve the legacy fallback for dual-hook resolvers (while keeping failures authoritative for default/sync-only resolvers), which likely requires exposing whether a distinct async hook is configured.
// Both walker entries gate on `canResolveSync()`, so the sync resolver's
// failure is authoritative in either mode - the async resolver runs the
// same algorithm. Bailing to the legacy path instead would execute
// already-resolved CJS deps before rediscovering the same error, where
// Node runs nothing when the graph fails to resolve.
const resolved = this.resolution.resolveEsm(
referencingIdentifier,
specifierPath,
);
| if (this._servesMockThroughEsm(from, moduleName)) { | ||
| mockRegistry.set( | ||
| moduleID, | ||
| this.esmLoader.requireEsmMock(from, moduleName), | ||
| ); |
| // Seeded before the load so a mock cycle resolves against the | ||
| // placeholder instead of recursing - same trick as `generateMock`. | ||
| this.mockState.setMockMetadata( | ||
| modulePath, | ||
| moduleMocker.getMetadata({}) ?? {}, | ||
| ); |
β¦e seam Runtime is a documented subclassing extension point; calling the core module provider directly meant an overridden requireModule never saw builtin loads coming from process.getBuiltinModule.
β¦resolvers A configured resolver may export distinct sync and async hooks that resolve differently; treating the sync failure as authoritative dropped the async hook's answer for dynamic imports. Expose Resolver#hasDistinctAsyncResolver and bail the sync-preferred walk to the legacy path only in that case - the default and sync-only resolvers keep the run-nothing-on-a-broken-graph ordering, and require() throws either way since it cannot await.
Generating a mock loads the real module, and its graph consulted mock decisions like any other walk - so in a synchronously evaluable cycle (a.mjs <-> b.mjs), generating A automocked B, whose generation loaded real B, which linked against A's empty metadata placeholder and failed with "does not provide an export named ...". Factory-less decisions now load the real module while a generation is in progress (tracked by a depth counter around the metadata load, which is fully synchronous); already-instantiated mocks and registered factories still serve. The metadata also becomes faithful to the real module instead of describing mocks of mocks; each dep's own automock generates at its own import edges.
β¦ackages The ESM mock delegation re-resolved the raw name with import conditions, so a conditional package whose require/module-sync and import conditions select different ESM files was mocked from the import target when require()d. Thread the CJS-resolved path through for the module ID and automock generation; the raw name still drives root manual-mock lookup. IDs derive from the resolved path, so require and import share one mock instance whenever both condition sets pick the same file.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 60 out of 70 changed files in this pull request and generated 1 comment.
Suppressed comments (1)
Previously missed (1) β in code that hasn't changed since the last review.
packages/jest-resolve/src/resolver.ts:432
- An async-only resolver also satisfies this condition, so
hasDistinctAsyncResolver()returnstrueeven though there is no sync interface to differ from. That contradicts the method's documented contract; require both hooks here (and cover the existing async-only resolver fixture in the test).
result =
typeof resolverModule !== 'function' &&
typeof resolverModule.async === 'function';
| // A name that only resolves to a manual mock has no ESM target. | ||
| return null; | ||
| } | ||
| return this._resolution.shouldLoadAsEsm(modulePath) ? modulePath : null; |
An async-only resolver matched the check despite having no sync interface to differ from, contradicting the documented contract. Its callers were unaffected - they gate on canResolveSync() first - but the answer was wrong on its own terms.
A .js file in a CommonJS scope whose transformed source carries ESM syntax loads through requireEsmModule's parse-error fallback, but the mock-target probe answered null for it - the CJS generateMock path then loaded the real module, whose fallback generated the ESM mock, and the outer path automocked that mock a second time: require() and import got different instances and onGenerateMock ran twice. Classify with the same hasEsmSyntax discriminator, keeping explicitly CommonJS files, .json, .node and core names on the CJS path.
| const mocked = this.importMockSync( | ||
| referencingIdentifier, | ||
| specifierPath, | ||
| moduleID, | ||
| context, | ||
| scratch, | ||
| mode, | ||
| ); |
Registered unstable_mockModule factories were the last user code still executing during resolution - their side effects ran before a later sibling's resolution or import-attribute error. Only already-built mock instances adopt eagerly now (that runs no user code); factory-backed decisions join the pending mock queue, whose drain already handles factories, async-factory registration and the generated path alike.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 63 out of 73 changed files in this pull request and generated no new comments.
Suppressed comments (2)
Previously missed (2) β in code that hasn't changed since the last review.
packages/jest-runtime/src/internals/EsmLoader.ts:1374
jest.deepUnmock()is recorded only in the CJS transitive map, but this bridge checks only the root's explicit-unmock bit. The root ESM module therefore loads for real while its ESM dependencies are still automocked, violatingdeepUnmock's documented guarantee that the module and its dependencies remain real. Propagate the CJS transitive-unmock state to the corresponding ESM module ID before walking the real graph.
packages/jest-runtime/src/internals/EsmLoader.ts:2247- This distinct-resolver guard is bypassed when a module mock already exists:
importMockreturns the cached entry above before reaching this branch. Ifrequire()first generated that entry with the sync hook, a later dynamic import reuses the sync target's mock even when the async hook resolves the same specifier elsewhere, contradicting the documented factory-less-mock exclusion for dual-hook resolvers. Apply the distinct-resolver check before reusing a cached generated mock (registered factories can still be reused).
β¦root jest.deepUnmock records its transitive mark under the CJS module ID; the require() unmock gate freed the root but the real graph's walk consulted the ESM ID of the root as importer, so its ESM dependencies stayed automocked - against deepUnmock's documented guarantee. Mirror the mark before walking; applyTransitive cascades from there as it does for CJS.
β¦hook resolver importMock returned a cached instance before the distinct-resolver guard, so a mock require() legitimately generated with the sync hook was reused by a dynamic import the documented exclusion covers. Cached factory instances still reuse - no resolution shaped them; generated ones fall through to the factory error.
| datasource | package | from | to | | ---------- | ------- | ------ | ------ | | npm | jest | 30.4.2 | 30.5.0 | ## [v30.5.0](https://github.com/jestjs/jest/blob/HEAD/CHANGELOG.md#3050) ##### Features - `[@jest/expect-utils, jest-mock]` Add `mockFn.whenCalledWith(...args)` for configuring return values per argument list, with first-class asymmetric-matcher support ([#16053](jestjs/jest#16053)) - `[@jest/expect-utils]` Export `AsymmetricMatcher` and `FunctionParameters` types (previously private to `expect`) ([#16053](jestjs/jest#16053)) - `[jest-circus, jest-core, jest-jasmine2, jest-test-result, jest-types]` `--collectTests` now expands `test.each`/`describe.each` cases and reports per-status counts (skipped/todo via the new `wouldRun` flag for selected tests) plus a summary line that match a real run, including under `--testNamePattern` and `.only`/`fdescribe` focus on both the circus and jasmine2 runners ([#16259](jestjs/jest#16259)) - `[jest-circus, jest-environment, jest-runtime, jest-types]` Add describe-level retries via `jest.retryTimes(..., {entireDescribe: true})` ([#16322](jestjs/jest#16322)) - `[jest-circus, jest-message-util, jest-reporters, jest-types]` Add `retryMessages` to `AssertionResult` and export `formatErrorStack`, so the retry log renders nested `cause` and `AggregateError` sections with code frames instead of serialized `[cause]:`/`[errors]:` markers ([#16316](jestjs/jest#16316)) - `[jest-circus, jest-types]` Add `unhandledErrorsDetailed` to `Circus.RunResult`, so an unhandled rejection reports its `cause` chain and `AggregateError` entries with code frames instead of a pre-serialized stack ([#16316](jestjs/jest#16316)) - `[jest-haste-map]` Replace `NodeWatcher` and `FSEventsWatcher` with `@parcel/watcher` for the non-watchman watch path ([#16188](jestjs/jest#16188)) - `[jest-resolve]` Bump `unrs-resolver` to 1.12.1, remove `jest-pnp-resolver` and unnecessary checks ([#15721](jestjs/jest#15721)) - `[jest-resolve]` Honor Node's `--preserve-symlinks` / `NODE_PRESERVE_SYMLINKS` in the default resolver by passing `symlinks: false` to `unrs-resolver` ([#16260](jestjs/jest#16260)) - `[jest-runtime]` Apply automocking and manual `__mocks__` files to synchronously evaluable ESM graphs on Node 24.9+ - static imports, dynamic `import()` and `require()` of an ESM file now generate an automock from the real module's namespace instead of failing with "Attempting to import a mock without a factory". Graphs that need async evaluation (top-level await) or an async-only resolver or transformer still throw ([#16391](jestjs/jest#16391)) - `[jest-runtime]` Route `process.getBuiltinModule` through the sandbox, so it returns the sandbox `process` and the hooked `node:module` instead of the host's ([#16391](jestjs/jest#16391)) - `[jest-runtime]` Throw an actionable error from `module.register()` and `module.registerHooks()` inside a test - the hooks attached to the loader running Jest itself, never saw the sandboxed requires they were meant for, and stayed registered for every later test file in the worker ([#16391](jestjs/jest#16391)) - `[jest-runtime]` Surface resolution and import-attribute errors in an ESM graph before executing any of its CJS dependencies on Node 24.9+, matching Node's run-nothing-on-a-broken-graph behavior; the legacy loader on older versions keeps its linking-time execution order ([#16391](jestjs/jest#16391)) - `[jest-runtime]` Throw `ERR_SOURCE_PHASE_NOT_DEFINED` with an actionable message for `import source` and `import.source()`, instead of failing at instantiation with V8's bare "Source phase import object is not defined" ([#16391](jestjs/jest#16391)) - `[jest-runtime]` Emit the JSON-without-import-attribute deprecation warning once per test file instead of once per worker, so it is no longer silently swallowed for every file after the first ([#16391](jestjs/jest#16391)) - `[jest-runtime]` Set `import.meta.main` to `true` in the test file and `false` in every module it loads, matching Node 24+ ([#16367](jestjs/jest#16367)) - `[jest-runtime]` Resolve the `module-sync` export condition, so a package that exposes its ESM entry point for `require()` loads the same file Node would ([#16336](jestjs/jest#16336)) - `[jest-snapshot]` Add external snapshot paths to custom reporter failure details ([#16374](jestjs/jest#16374)) ##### Fixes - `[jest-console, jest-reporters]` `CustomConsole` now buffers console output so `TestResult.console` is populated for reporters when `verbose` is enabled, while `GitHubActionsReporter` avoids replaying buffered output in verbose mode ([#16155](jestjs/jest#16155)) - `[expect, jest-message-util, jest-pattern, jest-regex-util, jest-util]` Revert `node:` protocol imports to restore webpack/browser-bundle compatibility ([#16167](jestjs/jest#16167)) - `[expect]` Widen `toMatchObject` and `objectContaining` parameter type from `Record<string, unknown>` to `object` so class instances are accepted ([#16196](jestjs/jest#16196)) - `[jest-circus]` Call a generator test body with the shared test context, so `this` matches what a regular test function receives ([#16347](jestjs/jest#16347)) - `[jest-circus]` Capture the error listeners of the parent process instead of the in-sandbox `process`, so listeners registered before the test file survive teardown and sandbox listeners no longer leak onto the parent ([#16347](jestjs/jest#16347)) - `[jest-circus]` Clear `currentlyRunningTest` after skipped and todo tests ([#16342](jestjs/jest#16342)) - `[jest-circus]` Prevent late `done()` callbacks from affecting later test or hook invocations ([#16343](jestjs/jest#16343)) - `[jest-circus, jest-jasmine2]` Honor `--expand` when formatting `node:assert` failures, instead of always collapsing the diff ([#16347](jestjs/jest#16347)) - `[jest-circus, jest-jasmine2, jest-message-util]` Serialize the inner errors of an `AggregateError` into `failureMessages`, `retryReasons` and `unhandledErrors`, so `--json` output and reporter annotations include them ([#16316](jestjs/jest#16316)) - `[jest-circus, jest-snapshot]` Keep snapshot state and counts correct when a test retries ([#16344](jestjs/jest#16344)) - `[@jest/create-cache-key-function]` Include the caller support flags in the generated key, so a transformer that emits ESM or CJS based on them no longer shares one cache entry between the two ([#16331](jestjs/jest#16331)) - `[@jest/create-cache-key-function]` Include the stringified project config in the generated key, so editing a transformer's own settings invalidates what it cached ([#16331](jestjs/jest#16331)) - `[@jest/transform]` Include the caller support flags in a transform's cache key, so a file transformed both as ESM and as CJS no longer serves one shape's output for the other ([#16331](jestjs/jest#16331)) - `[jest-config]` Add missing `findRelatedTests`, `outputFile`, and `replname` entries to `ValidConfig` so they no longer trigger spurious "Unknown option" warnings ([#16224](jestjs/jest#16224)) - `[jest-config]` Use `--config` for the global config when multiple `--projects` are specified ([#16273](jestjs/jest#16273)) - `[jest-core]` Serialize `bigint` values in `--json` and `--outputFile` output as their literal form (`4n`), instead of failing the run with `TypeError: Do not know how to serialize a BigInt` ([#16338](jestjs/jest#16338)) - `[jest-core]` Do not report a `CustomGC` async resource (used by N-API addons such as napi-rs for per-isolate GC bookkeeping) as an open handle, since it is `napi_unref`'d by the addon and can never keep the event loop alive ([#16379](jestjs/jest#16379)) - `[jest-each]` Keep a `$&`, `` $` ``, `$'` or `$$` inside a `%p` param value out of the replacement, so the title shows the value instead of the text around it ([#16338](jestjs/jest#16338)) - `[jest-each]` Interpolate a `bigint` into a `%j` title as its literal form (`"4n"`) at any depth, instead of throwing `TypeError: Do not know how to serialize a BigInt` while collecting the tests ([#16338](jestjs/jest#16338)) - `[jest-environment, jest-runtime]` Bind `sandboxInjectedGlobals` to the right values when `injectGlobals` is `false`, instead of shifting every one of them by a position ([#16377](jestjs/jest#16377)) - `[jest-environment-node, jest-util]` Only warn about a conflicting `globalsCleanup` mode when one was explicitly configured, and follow the mode that is actually in effect ([#16323](jestjs/jest#16323)) - `[jest-environment-node, jest-util]` Stop resolving lazy globals when setting up an environment, so Node 26's builtin module globals are no longer loaded (and no longer emit their deprecation warnings) for every test file ([#16324](jestjs/jest#16324)) - `[jest-haste-map]` Keep watch mode alive when an outside process briefly makes a file unreadable on Windows, instead of tearing the watcher down on `EPERM` ([#16295](jestjs/jest#16295)) - `[jest-haste-map]` Keep indexing when an outside process holds a file open on Windows, instead of failing the whole crawl on `EPERM` ([#16358](jestjs/jest#16358)) - `[jest-haste-map]` Keep a duplicated manual mock resolving when the file it pointed at is deleted in watch mode ([#16360](jestjs/jest#16360)) - `[jest-haste-map]` Shut the worker farm down when a duplicate manual mock aborts the build under `throwOnModuleCollision` ([#16354](jestjs/jest#16354)) - `[jest-haste-map]` Attach the watchman client's `error` listener before the first command, so a watchman failure falls back to the node crawler instead of crashing on an unhandled `error` event, and always end the client ([#16355](jestjs/jest#16355)) - `[jest-haste-map]` Stop delivering watch events after `WatchmanWatcher` is closed, and route its warnings through the configured console ([#16355](jestjs/jest#16355)) - `[jest-haste-map]` Restore the nested `duplicates` index correctly in `ModuleMap.fromJSON`, so a haste collision reported inside a test worker raises `DuplicateHasteCandidatesError` instead of a `TypeError` ([#16353](jestjs/jest#16353)) - `[jest-haste-map]` Match watched files on a full extension, so `moduleFileExtensions: ['js']` no longer accepts `foo.mjs` ([#16352](jestjs/jest#16352)) - `[jest-haste-map]` Delimit the fields that make up the haste map cache key, so two different option sets cannot hash to the same cache file ([#16352](jestjs/jest#16352)) - `[jest-message-util]` Print the inner errors of an `AggregateError` thrown inside a test ([#16316](jestjs/jest#16316)) - `[jest-message-util]` Indent nested `cause` and `AggregateError` sections of a test failure by one level per depth, so the nesting is legible instead of rendering flat ([#16316](jestjs/jest#16316)) - `[jest-message-util]` Color stack traces line by line so blank lines stay blank ([#16316](jestjs/jest#16316)) - `[jest-message-util]` Detect Jest's own frames without assuming the checkout directory's name, and cover `@jest/*` packages, so stack traces and code frames point at user code ([#16326](jestjs/jest#16326)) - `[jest-mock]` `mockResolvedValue` / `mockRejectedValue` now see all overload return types, so a Promise-returning overload survives even when a later overload returns a non-Promise (e.g. `pg.Client['end']`) ([#16237](jestjs/jest#16237)) - `[@jest-environment/jsdom-abstract]` Make `@types/jsdom` a peer dependency ([#16166](jestjs/jest#16166)) - `[jest-mock]` Remove the leftover own accessor descriptor when restoring a `spyOn` of an inherited getter or setter, so the instance keeps reflecting the prototype ([#16226](jestjs/jest#16226)) - `[jest-resolve]` Include `extensionsToTreatAsEsm` in the `shouldLoadAsEsm` cache key, so projects with different extension lists don't read each other's answers ([#16369](jestjs/jest#16369)) - `[jest-resolve]` Make `getModuleIDAsync` build and cache `data:` URI module IDs the same way as `getModuleID` ([#16370](jestjs/jest#16370)) - `[jest-resolve]` Keep the `node:` prefix when resolving a core module asynchronously, so a builtin that only exists prefixed (`node:sea`, `node:sqlite`, `node:test`, `node:test/reporters`) resolves instead of failing as a missing bare package ([#16388](jestjs/jest#16388)) - `[jest-resolve]` Look up manual mocks for `node:` protocol specifiers under the unprefixed name they are stored as ([#16388](jestjs/jest#16388)) - `[jest-resolve]` Apply `moduleNameMapper` consistently to both spellings of core module specifiers (`fs` vs `node:fs`) ([#16390](jestjs/jest#16390)) - `[jest-resolve]` Keep virtual and ordinary mock module IDs isolated across test files ([#16296](jestjs/jest#16296)) - `[jest-resolve]` Guard missing `require.resolve.paths` ([#16052](jestjs/jest#16052)) - `[jest-resolve, jest-config, jest-runner]` Support a user resolver written as an ES module ([#16332](jestjs/jest#16332)) - `[jest-resolve, jest-runtime]` Throw the CJS parse error for ESM syntax in a `"type": "commonjs"` package or a `.cjs` file instead of loading it as ESM, matching Node ([#16368](jestjs/jest#16368)) - `[@jest/source-map]` Keep source map sources that name a scheme, such as `webpack:///`, instead of resolving them into a path that does not exist ([#16327](jestjs/jest#16327)) - `[@jest/source-map]` Look up `--testLocationInResults` positions at the right column, and keep a mapping to the first column instead of discarding it ([#16327](jestjs/jest#16327)) - `[@jest/source-map]` Warn when a source map cannot be parsed, instead of silently leaving its frames untranslated ([#16327](jestjs/jest#16327)) - `[jest-runner, @jest/source-map]` Keep a source-mapped stack for an error thrown after the test environment was torn down ([#16327](jestjs/jest#16327)) - `[jest-runtime, @jest/source-map]` Keep source maps past teardown and past the next test file's `install`, so a stack from a file no earlier stack mentioned still points at the original source ([#16330](jestjs/jest#16330)) - `[jest-runtime]` Report that no coverage was collected when `getAllV8CoverageInfoCopy` is called after `teardown`, instead of returning an empty result ([#16385](jestjs/jest#16385)) - `[jest-runtime]` Cache a CJS module's parsed exports before walking its re-exports, so two modules that re-export each other no longer overflow the stack when imported from ESM ([#16363](jestjs/jest#16363)) - `[jest-runtime]` Keep a re-exported ES module's parse failure from marking the re-exporting CommonJS file as ESM, so `module.exports = require('./dep.mjs')` loads instead of failing with `module is not defined` ([#16363](jestjs/jest#16363)) - `[jest-runtime]` Scope module mocks instantiated inside `jest.isolateModules`/`isolateModulesAsync` to that block, so a mock first imported there no longer outlives it - matching how CommonJS mocks already behave ([#16365](jestjs/jest#16365)) - `[jest-runtime]` Suspend module isolation while generating an automock, so loading the real module to read its shape no longer populates the isolated registry ([#16365](jestjs/jest#16365)) - `[jest-runtime]` Check a cached ES module's status before `require()` returns it, so a module whose evaluation threw rethrows that error and one left linked by a failed sibling is evaluated instead of returning uninitialized bindings ([#16364](jestjs/jest#16364)) - `[jest-runtime]` Report the original `ERR_REQUIRE_ASYNC_MODULE` when a `require()` of a top-level-await graph is retried, instead of a spurious "concurrent `import()`" error ([#16364](jestjs/jest#16364)) - `[jest-runtime]` Throw the evaluation error when another caller's `import()` of the same module failed while we awaited it, instead of resolving with the errored module ([#16364](jestjs/jest#16364)) - `[jest-runtime]` Mark the result of `require()`ing an ES module that has a default export with `__esModule: true` through a live-binding facade, and serve the same object from `require.cache`, matching Node ([#16367](jestjs/jest#16367)) - `[jest-runtime]` Provide a CommonJS module's exports under the `'module.exports'` named export when imported from ESM, matching Node 23+ ([#16367](jestjs/jest#16367)) - `[jest-runtime]` Give the test file itself a non-null `require.main` ([#16367](jestjs/jest#16367)) - `[jest-runtime]` Populate `module.children` with the modules a file loads, matching Node ([#16368](jestjs/jest#16368)) - `[jest-runtime]` Provide `import.meta.resolve` and `import.meta.jest` in `data:` URI modules, accept any-case mediatype parameters, and use Node's error codes for invalid `data:` URIs ([#16368](jestjs/jest#16368)) - `[jest-runtime]` Key ES modules by full URL, so query and fragment suffixes create the same module instances as Node and show up in `import.meta.url` ([#16375](jestjs/jest#16375)) - `[jest-runtime]` Share modules between overlapping graphs when a CommonJS module `require()`s an ES module mid-load, instead of evaluating shared dependencies twice ([#16375](jestjs/jest#16375)) - `[jest-runtime]` Throw `ERR_REQUIRE_CYCLE_MODULE` like Node when a CommonJS module `require()`s an ES module that is still being loaded, instead of evaluating the module a second time ([#16366](jestjs/jest#16366)) - `[jest-runtime]` Key builtin modules in the ESM registry by one canonical specifier ([#16341](jestjs/jest#16341)) - `[jest-runtime]` `import.meta.resolve()` for a builtin uses its `node:` specifier ([#16341](jestjs/jest#16341)) - `[jest-runtime]` Fall back to native ESM when a `.js` file contains ESM syntax but has no `"type":"module"` marker ([#16152](jestjs/jest#16152)) - `[jest-runtime]` Allow `require()` of ESM-marked files on Node < 24.9 via transform fallback ([#16244](jestjs/jest#16244)) - `[jest-runtime, @jest/transform]` Surface actionable `ERR_REQUIRE_ESM` error for files with untransformed ESM syntax instead of the generic "unexpected token" message ([#16244](jestjs/jest#16244)) - `[jest-runtime]` Support older test environments whose `moduleMocker` does not implement `clearMocksOnScope` ([#16169](jestjs/jest#16169)) - `[jest-runtime]` Apply `jest.unstable_mockModule` when the mocked file itself is `require()`d, not only when it is imported as a dependency ([#16389](jestjs/jest#16389)) - `[jest-runtime]` Apply `jest.unstable_mockModule` to statically imported `data:` URIs on Node 24.9+, matching dynamic `import()` ([#16389](jestjs/jest#16389)) - `[jest-runtime]` Run an async `jest.unstable_mockModule` factory once per module instead of twice, and fail the import instead of crashing the worker when the factory rejects ([#16389](jestjs/jest#16389)) - `[jest-runtime]` Hide a `require(esm)` module that failed to evaluate from `require.cache`, as Node does, instead of exposing a namespace with uninitialized bindings ([#16389](jestjs/jest#16389)) - `[jest-runtime]` Strip the byte-order mark when importing a JSON module, matching `require()` and Node ([#16389](jestjs/jest#16389)) - `[jest-runtime]` Throw `ERR_REQUIRE_ASYNC_MODULE` when `require(esm)` runs under an async-only custom resolver, instead of silently resolving with the default resolver ([#16389](jestjs/jest#16389)) - `[jest-runtime]` Parse imported JSON modules with the test realm's `JSON`, so their objects pass `instanceof Object` inside the test like `require()`d JSON does ([#16389](jestjs/jest#16389)) - `[jest-runtime]` Accept every `file:` URL string in the sandboxed `module.createRequire`, including one with a `localhost` authority, as Node does ([#16389](jestjs/jest#16389)) - `[jest-runtime]` Point at `{virtual: true}` when `jest.mock` or `jest.unstable_mockModule` is given a module that cannot be resolved ([#16389](jestjs/jest#16389)) - `[jest-reporters]` Fix coverage report table formatting in CI/GitHub Actions environments where `process.stdout.columns` is undefined by falling back to the `COLUMNS` env var or `80` columns in CI, preserving existing behaviour in other non-TTY environments ([#16227](jestjs/jest#16227)) - `[jest-runtime]` Support CJS-in-ESM exports via `"module.exports"` named exports ([#16277](jestjs/jest#16277)) - `[jest-snapshot]` Keep a skipped or failed test's hinted snapshots, instead of reporting them obsolete ([#16348](jestjs/jest#16348)) - `[jest-util]` Stop `globsToMatcher` reusing a cached matcher compiled with different picomatch options, and keep its `dot: true` default when `dot` is passed as `undefined` ([#16381](jestjs/jest#16381)) - `[pretty-format]` Move the `react-is` aliases into the `@jest` scope, so they cannot be shadowed by unrelated packages published under the alias names ([#16333](jestjs/jest#16333)) ##### Chore & Maintenance - `[docs]` Document the intentional divergences from Node's module system in the ECMAScript Modules page ([#16368](jestjs/jest#16368)) - `[docs]` Note deprecation of `react-test-renderer` in React Native tutorial and `pretty-format` README ([#16294](jestjs/jest#16294)) - `[docs]` Use `@testing-library/react-native` in the React Native tutorial instead of the deprecated `react-test-renderer` ([#16318](jestjs/jest#16318)) - `[babel-jest, @jest/transform]` Update `babel-plugin-istanbul` to v8 ([#16049](jestjs/jest#16049)) - `[jest-config, @jest/reporters, jest-runtime]` Update `glob` to v13 ([#16397](jestjs/jest#16397)) - `[jest-haste-map]` Refactor massive class into multiple files ([#16180](jestjs/jest#16180)) - `[jest-haste-map]` Drop `walker` dependency; replace hand-rolled directory recursion in the JS crawler and watcher startup with `fdir` ([#16187](jestjs/jest#16187)) - `[jest-haste-map]` Reuse cached metadata for files whose haste name is a known duplicate, instead of re-reading and re-parsing them on every startup ([#16351](jestjs/jest#16351)) - `[jest-haste-map]` Cache the watchman socket path and replace the `watchman --version` probe with `get-sockname`, so warm runs spawn no watchman processes ([#16386](jestjs/jest#16386)) - `[jest-resolve]` Store the per-directory package-type lookup in the cache it reads, so it actually memoizes ([#16369](jestjs/jest#16369)) - `[jest-resolve, jest-runtime]` Cut repeated work on the resolution hot path: hoist the platform-extension list to construction, memoize `isCoreModule` and the options cache-key serialization, skip mapper preparation when no `moduleNameMapper` is configured, run each mapper regex once, and stop re-parsing `NODE_OPTIONS` on every default-resolver call ([#16371](jestjs/jest#16371)) - `[jest-resolve]` Cut warm resolution cost to about a third: reuse one `unrs-resolver` factory per options shape instead of cloning per resolution, compose the factory cache key from per-array cached strings instead of serializing options, and stop constructing an `Error` for misses that `findNodeModule` swallows; add a `__benchmarks__` suite for the default resolver ([#16373](jestjs/jest#16373)) - `[jest-runner, @jest/source-map]` Replace `source-map-support` with an implementation in `@jest/source-map` ([#16327](jestjs/jest#16327)) - `[jest-snapshot]` Load babel, semver and synckit lazily, so requiring the package (which every test process does through `@jest/expect`) no longer loads \~200 modules that only writing inline snapshots needs ([#16387](jestjs/jest#16387)) - `[jest-runtime]` Reduce per-require overhead: skip module ID resolution when no mock can apply, answer core modules before probing for a manual mock, share one `require.cache` proxy across modules, and cache empty files ([#16376](jestjs/jest#16376)) - `[@jest/source-map]` Deprecate `getCallsite` in favour of `SourceMapSupport#getCallsite` ([#16327](jestjs/jest#16327)) - `[jest-runtime]` Avoid magical `null` value in ESM loader ([#16160](jestjs/jest#16160))
| datasource | package | from | to | | ---------- | ------- | ------ | ------ | | npm | jest | 30.4.2 | 30.5.0 | ## [v30.5.0](https://github.com/jestjs/jest/blob/HEAD/CHANGELOG.md#3050) ##### Features - `[@jest/expect-utils, jest-mock]` Add `mockFn.whenCalledWith(...args)` for configuring return values per argument list, with first-class asymmetric-matcher support ([#16053](jestjs/jest#16053)) - `[@jest/expect-utils]` Export `AsymmetricMatcher` and `FunctionParameters` types (previously private to `expect`) ([#16053](jestjs/jest#16053)) - `[jest-circus, jest-core, jest-jasmine2, jest-test-result, jest-types]` `--collectTests` now expands `test.each`/`describe.each` cases and reports per-status counts (skipped/todo via the new `wouldRun` flag for selected tests) plus a summary line that match a real run, including under `--testNamePattern` and `.only`/`fdescribe` focus on both the circus and jasmine2 runners ([#16259](jestjs/jest#16259)) - `[jest-circus, jest-environment, jest-runtime, jest-types]` Add describe-level retries via `jest.retryTimes(..., {entireDescribe: true})` ([#16322](jestjs/jest#16322)) - `[jest-circus, jest-message-util, jest-reporters, jest-types]` Add `retryMessages` to `AssertionResult` and export `formatErrorStack`, so the retry log renders nested `cause` and `AggregateError` sections with code frames instead of serialized `[cause]:`/`[errors]:` markers ([#16316](jestjs/jest#16316)) - `[jest-circus, jest-types]` Add `unhandledErrorsDetailed` to `Circus.RunResult`, so an unhandled rejection reports its `cause` chain and `AggregateError` entries with code frames instead of a pre-serialized stack ([#16316](jestjs/jest#16316)) - `[jest-haste-map]` Replace `NodeWatcher` and `FSEventsWatcher` with `@parcel/watcher` for the non-watchman watch path ([#16188](jestjs/jest#16188)) - `[jest-resolve]` Bump `unrs-resolver` to 1.12.1, remove `jest-pnp-resolver` and unnecessary checks ([#15721](jestjs/jest#15721)) - `[jest-resolve]` Honor Node's `--preserve-symlinks` / `NODE_PRESERVE_SYMLINKS` in the default resolver by passing `symlinks: false` to `unrs-resolver` ([#16260](jestjs/jest#16260)) - `[jest-runtime]` Apply automocking and manual `__mocks__` files to synchronously evaluable ESM graphs on Node 24.9+ - static imports, dynamic `import()` and `require()` of an ESM file now generate an automock from the real module's namespace instead of failing with "Attempting to import a mock without a factory". Graphs that need async evaluation (top-level await) or an async-only resolver or transformer still throw ([#16391](jestjs/jest#16391)) - `[jest-runtime]` Route `process.getBuiltinModule` through the sandbox, so it returns the sandbox `process` and the hooked `node:module` instead of the host's ([#16391](jestjs/jest#16391)) - `[jest-runtime]` Throw an actionable error from `module.register()` and `module.registerHooks()` inside a test - the hooks attached to the loader running Jest itself, never saw the sandboxed requires they were meant for, and stayed registered for every later test file in the worker ([#16391](jestjs/jest#16391)) - `[jest-runtime]` Surface resolution and import-attribute errors in an ESM graph before executing any of its CJS dependencies on Node 24.9+, matching Node's run-nothing-on-a-broken-graph behavior; the legacy loader on older versions keeps its linking-time execution order ([#16391](jestjs/jest#16391)) - `[jest-runtime]` Throw `ERR_SOURCE_PHASE_NOT_DEFINED` with an actionable message for `import source` and `import.source()`, instead of failing at instantiation with V8's bare "Source phase import object is not defined" ([#16391](jestjs/jest#16391)) - `[jest-runtime]` Emit the JSON-without-import-attribute deprecation warning once per test file instead of once per worker, so it is no longer silently swallowed for every file after the first ([#16391](jestjs/jest#16391)) - `[jest-runtime]` Set `import.meta.main` to `true` in the test file and `false` in every module it loads, matching Node 24+ ([#16367](jestjs/jest#16367)) - `[jest-runtime]` Resolve the `module-sync` export condition, so a package that exposes its ESM entry point for `require()` loads the same file Node would ([#16336](jestjs/jest#16336)) - `[jest-snapshot]` Add external snapshot paths to custom reporter failure details ([#16374](jestjs/jest#16374)) ##### Fixes - `[jest-console, jest-reporters]` `CustomConsole` now buffers console output so `TestResult.console` is populated for reporters when `verbose` is enabled, while `GitHubActionsReporter` avoids replaying buffered output in verbose mode ([#16155](jestjs/jest#16155)) - `[expect, jest-message-util, jest-pattern, jest-regex-util, jest-util]` Revert `node:` protocol imports to restore webpack/browser-bundle compatibility ([#16167](jestjs/jest#16167)) - `[expect]` Widen `toMatchObject` and `objectContaining` parameter type from `Record<string, unknown>` to `object` so class instances are accepted ([#16196](jestjs/jest#16196)) - `[jest-circus]` Call a generator test body with the shared test context, so `this` matches what a regular test function receives ([#16347](jestjs/jest#16347)) - `[jest-circus]` Capture the error listeners of the parent process instead of the in-sandbox `process`, so listeners registered before the test file survive teardown and sandbox listeners no longer leak onto the parent ([#16347](jestjs/jest#16347)) - `[jest-circus]` Clear `currentlyRunningTest` after skipped and todo tests ([#16342](jestjs/jest#16342)) - `[jest-circus]` Prevent late `done()` callbacks from affecting later test or hook invocations ([#16343](jestjs/jest#16343)) - `[jest-circus, jest-jasmine2]` Honor `--expand` when formatting `node:assert` failures, instead of always collapsing the diff ([#16347](jestjs/jest#16347)) - `[jest-circus, jest-jasmine2, jest-message-util]` Serialize the inner errors of an `AggregateError` into `failureMessages`, `retryReasons` and `unhandledErrors`, so `--json` output and reporter annotations include them ([#16316](jestjs/jest#16316)) - `[jest-circus, jest-snapshot]` Keep snapshot state and counts correct when a test retries ([#16344](jestjs/jest#16344)) - `[@jest/create-cache-key-function]` Include the caller support flags in the generated key, so a transformer that emits ESM or CJS based on them no longer shares one cache entry between the two ([#16331](jestjs/jest#16331)) - `[@jest/create-cache-key-function]` Include the stringified project config in the generated key, so editing a transformer's own settings invalidates what it cached ([#16331](jestjs/jest#16331)) - `[@jest/transform]` Include the caller support flags in a transform's cache key, so a file transformed both as ESM and as CJS no longer serves one shape's output for the other ([#16331](jestjs/jest#16331)) - `[jest-config]` Add missing `findRelatedTests`, `outputFile`, and `replname` entries to `ValidConfig` so they no longer trigger spurious "Unknown option" warnings ([#16224](jestjs/jest#16224)) - `[jest-config]` Use `--config` for the global config when multiple `--projects` are specified ([#16273](jestjs/jest#16273)) - `[jest-core]` Serialize `bigint` values in `--json` and `--outputFile` output as their literal form (`4n`), instead of failing the run with `TypeError: Do not know how to serialize a BigInt` ([#16338](jestjs/jest#16338)) - `[jest-core]` Do not report a `CustomGC` async resource (used by N-API addons such as napi-rs for per-isolate GC bookkeeping) as an open handle, since it is `napi_unref`'d by the addon and can never keep the event loop alive ([#16379](jestjs/jest#16379)) - `[jest-each]` Keep a `$&`, `` $` ``, `$'` or `$$` inside a `%p` param value out of the replacement, so the title shows the value instead of the text around it ([#16338](jestjs/jest#16338)) - `[jest-each]` Interpolate a `bigint` into a `%j` title as its literal form (`"4n"`) at any depth, instead of throwing `TypeError: Do not know how to serialize a BigInt` while collecting the tests ([#16338](jestjs/jest#16338)) - `[jest-environment, jest-runtime]` Bind `sandboxInjectedGlobals` to the right values when `injectGlobals` is `false`, instead of shifting every one of them by a position ([#16377](jestjs/jest#16377)) - `[jest-environment-node, jest-util]` Only warn about a conflicting `globalsCleanup` mode when one was explicitly configured, and follow the mode that is actually in effect ([#16323](jestjs/jest#16323)) - `[jest-environment-node, jest-util]` Stop resolving lazy globals when setting up an environment, so Node 26's builtin module globals are no longer loaded (and no longer emit their deprecation warnings) for every test file ([#16324](jestjs/jest#16324)) - `[jest-haste-map]` Keep watch mode alive when an outside process briefly makes a file unreadable on Windows, instead of tearing the watcher down on `EPERM` ([#16295](jestjs/jest#16295)) - `[jest-haste-map]` Keep indexing when an outside process holds a file open on Windows, instead of failing the whole crawl on `EPERM` ([#16358](jestjs/jest#16358)) - `[jest-haste-map]` Keep a duplicated manual mock resolving when the file it pointed at is deleted in watch mode ([#16360](jestjs/jest#16360)) - `[jest-haste-map]` Shut the worker farm down when a duplicate manual mock aborts the build under `throwOnModuleCollision` ([#16354](jestjs/jest#16354)) - `[jest-haste-map]` Attach the watchman client's `error` listener before the first command, so a watchman failure falls back to the node crawler instead of crashing on an unhandled `error` event, and always end the client ([#16355](jestjs/jest#16355)) - `[jest-haste-map]` Stop delivering watch events after `WatchmanWatcher` is closed, and route its warnings through the configured console ([#16355](jestjs/jest#16355)) - `[jest-haste-map]` Restore the nested `duplicates` index correctly in `ModuleMap.fromJSON`, so a haste collision reported inside a test worker raises `DuplicateHasteCandidatesError` instead of a `TypeError` ([#16353](jestjs/jest#16353)) - `[jest-haste-map]` Match watched files on a full extension, so `moduleFileExtensions: ['js']` no longer accepts `foo.mjs` ([#16352](jestjs/jest#16352)) - `[jest-haste-map]` Delimit the fields that make up the haste map cache key, so two different option sets cannot hash to the same cache file ([#16352](jestjs/jest#16352)) - `[jest-message-util]` Print the inner errors of an `AggregateError` thrown inside a test ([#16316](jestjs/jest#16316)) - `[jest-message-util]` Indent nested `cause` and `AggregateError` sections of a test failure by one level per depth, so the nesting is legible instead of rendering flat ([#16316](jestjs/jest#16316)) - `[jest-message-util]` Color stack traces line by line so blank lines stay blank ([#16316](jestjs/jest#16316)) - `[jest-message-util]` Detect Jest's own frames without assuming the checkout directory's name, and cover `@jest/*` packages, so stack traces and code frames point at user code ([#16326](jestjs/jest#16326)) - `[jest-mock]` `mockResolvedValue` / `mockRejectedValue` now see all overload return types, so a Promise-returning overload survives even when a later overload returns a non-Promise (e.g. `pg.Client['end']`) ([#16237](jestjs/jest#16237)) - `[@jest-environment/jsdom-abstract]` Make `@types/jsdom` a peer dependency ([#16166](jestjs/jest#16166)) - `[jest-mock]` Remove the leftover own accessor descriptor when restoring a `spyOn` of an inherited getter or setter, so the instance keeps reflecting the prototype ([#16226](jestjs/jest#16226)) - `[jest-resolve]` Include `extensionsToTreatAsEsm` in the `shouldLoadAsEsm` cache key, so projects with different extension lists don't read each other's answers ([#16369](jestjs/jest#16369)) - `[jest-resolve]` Make `getModuleIDAsync` build and cache `data:` URI module IDs the same way as `getModuleID` ([#16370](jestjs/jest#16370)) - `[jest-resolve]` Keep the `node:` prefix when resolving a core module asynchronously, so a builtin that only exists prefixed (`node:sea`, `node:sqlite`, `node:test`, `node:test/reporters`) resolves instead of failing as a missing bare package ([#16388](jestjs/jest#16388)) - `[jest-resolve]` Look up manual mocks for `node:` protocol specifiers under the unprefixed name they are stored as ([#16388](jestjs/jest#16388)) - `[jest-resolve]` Apply `moduleNameMapper` consistently to both spellings of core module specifiers (`fs` vs `node:fs`) ([#16390](jestjs/jest#16390)) - `[jest-resolve]` Keep virtual and ordinary mock module IDs isolated across test files ([#16296](jestjs/jest#16296)) - `[jest-resolve]` Guard missing `require.resolve.paths` ([#16052](jestjs/jest#16052)) - `[jest-resolve, jest-config, jest-runner]` Support a user resolver written as an ES module ([#16332](jestjs/jest#16332)) - `[jest-resolve, jest-runtime]` Throw the CJS parse error for ESM syntax in a `"type": "commonjs"` package or a `.cjs` file instead of loading it as ESM, matching Node ([#16368](jestjs/jest#16368)) - `[@jest/source-map]` Keep source map sources that name a scheme, such as `webpack:///`, instead of resolving them into a path that does not exist ([#16327](jestjs/jest#16327)) - `[@jest/source-map]` Look up `--testLocationInResults` positions at the right column, and keep a mapping to the first column instead of discarding it ([#16327](jestjs/jest#16327)) - `[@jest/source-map]` Warn when a source map cannot be parsed, instead of silently leaving its frames untranslated ([#16327](jestjs/jest#16327)) - `[jest-runner, @jest/source-map]` Keep a source-mapped stack for an error thrown after the test environment was torn down ([#16327](jestjs/jest#16327)) - `[jest-runtime, @jest/source-map]` Keep source maps past teardown and past the next test file's `install`, so a stack from a file no earlier stack mentioned still points at the original source ([#16330](jestjs/jest#16330)) - `[jest-runtime]` Report that no coverage was collected when `getAllV8CoverageInfoCopy` is called after `teardown`, instead of returning an empty result ([#16385](jestjs/jest#16385)) - `[jest-runtime]` Cache a CJS module's parsed exports before walking its re-exports, so two modules that re-export each other no longer overflow the stack when imported from ESM ([#16363](jestjs/jest#16363)) - `[jest-runtime]` Keep a re-exported ES module's parse failure from marking the re-exporting CommonJS file as ESM, so `module.exports = require('./dep.mjs')` loads instead of failing with `module is not defined` ([#16363](jestjs/jest#16363)) - `[jest-runtime]` Scope module mocks instantiated inside `jest.isolateModules`/`isolateModulesAsync` to that block, so a mock first imported there no longer outlives it - matching how CommonJS mocks already behave ([#16365](jestjs/jest#16365)) - `[jest-runtime]` Suspend module isolation while generating an automock, so loading the real module to read its shape no longer populates the isolated registry ([#16365](jestjs/jest#16365)) - `[jest-runtime]` Check a cached ES module's status before `require()` returns it, so a module whose evaluation threw rethrows that error and one left linked by a failed sibling is evaluated instead of returning uninitialized bindings ([#16364](jestjs/jest#16364)) - `[jest-runtime]` Report the original `ERR_REQUIRE_ASYNC_MODULE` when a `require()` of a top-level-await graph is retried, instead of a spurious "concurrent `import()`" error ([#16364](jestjs/jest#16364)) - `[jest-runtime]` Throw the evaluation error when another caller's `import()` of the same module failed while we awaited it, instead of resolving with the errored module ([#16364](jestjs/jest#16364)) - `[jest-runtime]` Mark the result of `require()`ing an ES module that has a default export with `__esModule: true` through a live-binding facade, and serve the same object from `require.cache`, matching Node ([#16367](jestjs/jest#16367)) - `[jest-runtime]` Provide a CommonJS module's exports under the `'module.exports'` named export when imported from ESM, matching Node 23+ ([#16367](jestjs/jest#16367)) - `[jest-runtime]` Give the test file itself a non-null `require.main` ([#16367](jestjs/jest#16367)) - `[jest-runtime]` Populate `module.children` with the modules a file loads, matching Node ([#16368](jestjs/jest#16368)) - `[jest-runtime]` Provide `import.meta.resolve` and `import.meta.jest` in `data:` URI modules, accept any-case mediatype parameters, and use Node's error codes for invalid `data:` URIs ([#16368](jestjs/jest#16368)) - `[jest-runtime]` Key ES modules by full URL, so query and fragment suffixes create the same module instances as Node and show up in `import.meta.url` ([#16375](jestjs/jest#16375)) - `[jest-runtime]` Share modules between overlapping graphs when a CommonJS module `require()`s an ES module mid-load, instead of evaluating shared dependencies twice ([#16375](jestjs/jest#16375)) - `[jest-runtime]` Throw `ERR_REQUIRE_CYCLE_MODULE` like Node when a CommonJS module `require()`s an ES module that is still being loaded, instead of evaluating the module a second time ([#16366](jestjs/jest#16366)) - `[jest-runtime]` Key builtin modules in the ESM registry by one canonical specifier ([#16341](jestjs/jest#16341)) - `[jest-runtime]` `import.meta.resolve()` for a builtin uses its `node:` specifier ([#16341](jestjs/jest#16341)) - `[jest-runtime]` Fall back to native ESM when a `.js` file contains ESM syntax but has no `"type":"module"` marker ([#16152](jestjs/jest#16152)) - `[jest-runtime]` Allow `require()` of ESM-marked files on Node < 24.9 via transform fallback ([#16244](jestjs/jest#16244)) - `[jest-runtime, @jest/transform]` Surface actionable `ERR_REQUIRE_ESM` error for files with untransformed ESM syntax instead of the generic "unexpected token" message ([#16244](jestjs/jest#16244)) - `[jest-runtime]` Support older test environments whose `moduleMocker` does not implement `clearMocksOnScope` ([#16169](jestjs/jest#16169)) - `[jest-runtime]` Apply `jest.unstable_mockModule` when the mocked file itself is `require()`d, not only when it is imported as a dependency ([#16389](jestjs/jest#16389)) - `[jest-runtime]` Apply `jest.unstable_mockModule` to statically imported `data:` URIs on Node 24.9+, matching dynamic `import()` ([#16389](jestjs/jest#16389)) - `[jest-runtime]` Run an async `jest.unstable_mockModule` factory once per module instead of twice, and fail the import instead of crashing the worker when the factory rejects ([#16389](jestjs/jest#16389)) - `[jest-runtime]` Hide a `require(esm)` module that failed to evaluate from `require.cache`, as Node does, instead of exposing a namespace with uninitialized bindings ([#16389](jestjs/jest#16389)) - `[jest-runtime]` Strip the byte-order mark when importing a JSON module, matching `require()` and Node ([#16389](jestjs/jest#16389)) - `[jest-runtime]` Throw `ERR_REQUIRE_ASYNC_MODULE` when `require(esm)` runs under an async-only custom resolver, instead of silently resolving with the default resolver ([#16389](jestjs/jest#16389)) - `[jest-runtime]` Parse imported JSON modules with the test realm's `JSON`, so their objects pass `instanceof Object` inside the test like `require()`d JSON does ([#16389](jestjs/jest#16389)) - `[jest-runtime]` Accept every `file:` URL string in the sandboxed `module.createRequire`, including one with a `localhost` authority, as Node does ([#16389](jestjs/jest#16389)) - `[jest-runtime]` Point at `{virtual: true}` when `jest.mock` or `jest.unstable_mockModule` is given a module that cannot be resolved ([#16389](jestjs/jest#16389)) - `[jest-reporters]` Fix coverage report table formatting in CI/GitHub Actions environments where `process.stdout.columns` is undefined by falling back to the `COLUMNS` env var or `80` columns in CI, preserving existing behaviour in other non-TTY environments ([#16227](jestjs/jest#16227)) - `[jest-runtime]` Support CJS-in-ESM exports via `"module.exports"` named exports ([#16277](jestjs/jest#16277)) - `[jest-snapshot]` Keep a skipped or failed test's hinted snapshots, instead of reporting them obsolete ([#16348](jestjs/jest#16348)) - `[jest-util]` Stop `globsToMatcher` reusing a cached matcher compiled with different picomatch options, and keep its `dot: true` default when `dot` is passed as `undefined` ([#16381](jestjs/jest#16381)) - `[pretty-format]` Move the `react-is` aliases into the `@jest` scope, so they cannot be shadowed by unrelated packages published under the alias names ([#16333](jestjs/jest#16333)) ##### Chore & Maintenance - `[docs]` Document the intentional divergences from Node's module system in the ECMAScript Modules page ([#16368](jestjs/jest#16368)) - `[docs]` Note deprecation of `react-test-renderer` in React Native tutorial and `pretty-format` README ([#16294](jestjs/jest#16294)) - `[docs]` Use `@testing-library/react-native` in the React Native tutorial instead of the deprecated `react-test-renderer` ([#16318](jestjs/jest#16318)) - `[babel-jest, @jest/transform]` Update `babel-plugin-istanbul` to v8 ([#16049](jestjs/jest#16049)) - `[jest-config, @jest/reporters, jest-runtime]` Update `glob` to v13 ([#16397](jestjs/jest#16397)) - `[jest-haste-map]` Refactor massive class into multiple files ([#16180](jestjs/jest#16180)) - `[jest-haste-map]` Drop `walker` dependency; replace hand-rolled directory recursion in the JS crawler and watcher startup with `fdir` ([#16187](jestjs/jest#16187)) - `[jest-haste-map]` Reuse cached metadata for files whose haste name is a known duplicate, instead of re-reading and re-parsing them on every startup ([#16351](jestjs/jest#16351)) - `[jest-haste-map]` Cache the watchman socket path and replace the `watchman --version` probe with `get-sockname`, so warm runs spawn no watchman processes ([#16386](jestjs/jest#16386)) - `[jest-resolve]` Store the per-directory package-type lookup in the cache it reads, so it actually memoizes ([#16369](jestjs/jest#16369)) - `[jest-resolve, jest-runtime]` Cut repeated work on the resolution hot path: hoist the platform-extension list to construction, memoize `isCoreModule` and the options cache-key serialization, skip mapper preparation when no `moduleNameMapper` is configured, run each mapper regex once, and stop re-parsing `NODE_OPTIONS` on every default-resolver call ([#16371](jestjs/jest#16371)) - `[jest-resolve]` Cut warm resolution cost to about a third: reuse one `unrs-resolver` factory per options shape instead of cloning per resolution, compose the factory cache key from per-array cached strings instead of serializing options, and stop constructing an `Error` for misses that `findNodeModule` swallows; add a `__benchmarks__` suite for the default resolver ([#16373](jestjs/jest#16373)) - `[jest-runner, @jest/source-map]` Replace `source-map-support` with an implementation in `@jest/source-map` ([#16327](jestjs/jest#16327)) - `[jest-snapshot]` Load babel, semver and synckit lazily, so requiring the package (which every test process does through `@jest/expect`) no longer loads \~200 modules that only writing inline snapshots needs ([#16387](jestjs/jest#16387)) - `[jest-runtime]` Reduce per-require overhead: skip module ID resolution when no mock can apply, answer core modules before probing for a manual mock, share one `require.cache` proxy across modules, and cache empty files ([#16376](jestjs/jest#16376)) - `[@jest/source-map]` Deprecate `getCallsite` in favour of `SourceMapSupport#getCallsite` ([#16327](jestjs/jest#16327)) - `[jest-runtime]` Avoid magical `null` value in ESM loader ([#16160](jestjs/jest#16160))
| datasource | package | from | to | | ---------- | ------- | ------ | ------ | | npm | jest | 30.4.2 | 30.5.1 | ## [v30.5.1](https://github.com/jestjs/jest/blob/HEAD/CHANGELOG.md#3051) ##### Fixes - `[jest-config]` Don't warn about global-only options in the config that supplies the global config - the root config a project resolves to, or the first entry of `--projects` when no root config is passed ([#16411](jestjs/jest#16411)) - `[jest-config, jest-types]` Stop accepting `reporters`, `coverageReporters`, `workerIdleMemoryLimit`, `cwd` and `runnerOptions` in a project config - they were silently ignored, and now warn like the other global-only options ([#16411](jestjs/jest#16411)) - `[jest-config, jest-validate]` Warn about `maxWorkers` and `coverageThreshold` in a project config instead of dropping them without a word ([#16411](jestjs/jest#16411)) - `[jest-resolve]` Match `moduleNameMapper` patterns against the specifier as written again (reverting [#16390](jestjs/jest#16390)) ([#16417](jestjs/jest#16417)) - `[jest-runtime]` Resolve package `imports` specifiers like `#dep` under ESM again ([#16413](jestjs/jest#16413)) ##### Chore & Maintenance - `[jest-util]` Name the `testEnvironmentOptions.globalsCleanup` option and link the docs from the `JEST-01` deprecation warning, and document the option's modes ([#16404](jestjs/jest#16404)) ## [v30.5.0](https://github.com/jestjs/jest/blob/HEAD/CHANGELOG.md#3050) ##### Features - `[@jest/expect-utils, jest-mock]` Add `mockFn.whenCalledWith(...args)` for configuring return values per argument list, with first-class asymmetric-matcher support ([#16053](jestjs/jest#16053)) - `[@jest/expect-utils]` Export `AsymmetricMatcher` and `FunctionParameters` types (previously private to `expect`) ([#16053](jestjs/jest#16053)) - `[jest-circus, jest-core, jest-jasmine2, jest-test-result, jest-types]` `--collectTests` now expands `test.each`/`describe.each` cases and reports per-status counts (skipped/todo via the new `wouldRun` flag for selected tests) plus a summary line that match a real run, including under `--testNamePattern` and `.only`/`fdescribe` focus on both the circus and jasmine2 runners ([#16259](jestjs/jest#16259)) - `[jest-circus, jest-environment, jest-runtime, jest-types]` Add describe-level retries via `jest.retryTimes(..., {entireDescribe: true})` ([#16322](jestjs/jest#16322)) - `[jest-circus, jest-message-util, jest-reporters, jest-types]` Add `retryMessages` to `AssertionResult` and export `formatErrorStack`, so the retry log renders nested `cause` and `AggregateError` sections with code frames instead of serialized `[cause]:`/`[errors]:` markers ([#16316](jestjs/jest#16316)) - `[jest-circus, jest-types]` Add `unhandledErrorsDetailed` to `Circus.RunResult`, so an unhandled rejection reports its `cause` chain and `AggregateError` entries with code frames instead of a pre-serialized stack ([#16316](jestjs/jest#16316)) - `[jest-haste-map]` Replace `NodeWatcher` and `FSEventsWatcher` with `@parcel/watcher` for the non-watchman watch path ([#16188](jestjs/jest#16188)) - `[jest-resolve]` Bump `unrs-resolver` to 1.12.1, remove `jest-pnp-resolver` and unnecessary checks ([#15721](jestjs/jest#15721)) - `[jest-resolve]` Honor Node's `--preserve-symlinks` / `NODE_PRESERVE_SYMLINKS` in the default resolver by passing `symlinks: false` to `unrs-resolver` ([#16260](jestjs/jest#16260)) - `[jest-runtime]` Apply automocking and manual `__mocks__` files to synchronously evaluable ESM graphs on Node 24.9+ - static imports, dynamic `import()` and `require()` of an ESM file now generate an automock from the real module's namespace instead of failing with "Attempting to import a mock without a factory". Graphs that need async evaluation (top-level await) or an async-only resolver or transformer still throw ([#16391](jestjs/jest#16391)) - `[jest-runtime]` Route `process.getBuiltinModule` through the sandbox, so it returns the sandbox `process` and the hooked `node:module` instead of the host's ([#16391](jestjs/jest#16391)) - `[jest-runtime]` Throw an actionable error from `module.register()` and `module.registerHooks()` inside a test - the hooks attached to the loader running Jest itself, never saw the sandboxed requires they were meant for, and stayed registered for every later test file in the worker ([#16391](jestjs/jest#16391)) - `[jest-runtime]` Surface resolution and import-attribute errors in an ESM graph before executing any of its CJS dependencies on Node 24.9+, matching Node's run-nothing-on-a-broken-graph behavior; the legacy loader on older versions keeps its linking-time execution order ([#16391](jestjs/jest#16391)) - `[jest-runtime]` Throw `ERR_SOURCE_PHASE_NOT_DEFINED` with an actionable message for `import source` and `import.source()`, instead of failing at instantiation with V8's bare "Source phase import object is not defined" ([#16391](jestjs/jest#16391)) - `[jest-runtime]` Emit the JSON-without-import-attribute deprecation warning once per test file instead of once per worker, so it is no longer silently swallowed for every file after the first ([#16391](jestjs/jest#16391)) - `[jest-runtime]` Set `import.meta.main` to `true` in the test file and `false` in every module it loads, matching Node 24+ ([#16367](jestjs/jest#16367)) - `[jest-runtime]` Resolve the `module-sync` export condition, so a package that exposes its ESM entry point for `require()` loads the same file Node would ([#16336](jestjs/jest#16336)) - `[jest-snapshot]` Add external snapshot paths to custom reporter failure details ([#16374](jestjs/jest#16374)) ##### Fixes - `[jest-console, jest-reporters]` `CustomConsole` now buffers console output so `TestResult.console` is populated for reporters when `verbose` is enabled, while `GitHubActionsReporter` avoids replaying buffered output in verbose mode ([#16155](jestjs/jest#16155)) - `[expect, jest-message-util, jest-pattern, jest-regex-util, jest-util]` Revert `node:` protocol imports to restore webpack/browser-bundle compatibility ([#16167](jestjs/jest#16167)) - `[expect]` Widen `toMatchObject` and `objectContaining` parameter type from `Record<string, unknown>` to `object` so class instances are accepted ([#16196](jestjs/jest#16196)) - `[jest-circus]` Call a generator test body with the shared test context, so `this` matches what a regular test function receives ([#16347](jestjs/jest#16347)) - `[jest-circus]` Capture the error listeners of the parent process instead of the in-sandbox `process`, so listeners registered before the test file survive teardown and sandbox listeners no longer leak onto the parent ([#16347](jestjs/jest#16347)) - `[jest-circus]` Clear `currentlyRunningTest` after skipped and todo tests ([#16342](jestjs/jest#16342)) - `[jest-circus]` Prevent late `done()` callbacks from affecting later test or hook invocations ([#16343](jestjs/jest#16343)) - `[jest-circus, jest-jasmine2]` Honor `--expand` when formatting `node:assert` failures, instead of always collapsing the diff ([#16347](jestjs/jest#16347)) - `[jest-circus, jest-jasmine2, jest-message-util]` Serialize the inner errors of an `AggregateError` into `failureMessages`, `retryReasons` and `unhandledErrors`, so `--json` output and reporter annotations include them ([#16316](jestjs/jest#16316)) - `[jest-circus, jest-snapshot]` Keep snapshot state and counts correct when a test retries ([#16344](jestjs/jest#16344)) - `[@jest/create-cache-key-function]` Include the caller support flags in the generated key, so a transformer that emits ESM or CJS based on them no longer shares one cache entry between the two ([#16331](jestjs/jest#16331)) - `[@jest/create-cache-key-function]` Include the stringified project config in the generated key, so editing a transformer's own settings invalidates what it cached ([#16331](jestjs/jest#16331)) - `[@jest/transform]` Include the caller support flags in a transform's cache key, so a file transformed both as ESM and as CJS no longer serves one shape's output for the other ([#16331](jestjs/jest#16331)) - `[jest-config]` Add missing `findRelatedTests`, `outputFile`, and `replname` entries to `ValidConfig` so they no longer trigger spurious "Unknown option" warnings ([#16224](jestjs/jest#16224)) - `[jest-config]` Use `--config` for the global config when multiple `--projects` are specified ([#16273](jestjs/jest#16273)) - `[jest-core]` Serialize `bigint` values in `--json` and `--outputFile` output as their literal form (`4n`), instead of failing the run with `TypeError: Do not know how to serialize a BigInt` ([#16338](jestjs/jest#16338)) - `[jest-core]` Do not report a `CustomGC` async resource (used by N-API addons such as napi-rs for per-isolate GC bookkeeping) as an open handle, since it is `napi_unref`'d by the addon and can never keep the event loop alive ([#16379](jestjs/jest#16379)) - `[jest-each]` Keep a `$&`, `` $` ``, `$'` or `$$` inside a `%p` param value out of the replacement, so the title shows the value instead of the text around it ([#16338](jestjs/jest#16338)) - `[jest-each]` Interpolate a `bigint` into a `%j` title as its literal form (`"4n"`) at any depth, instead of throwing `TypeError: Do not know how to serialize a BigInt` while collecting the tests ([#16338](jestjs/jest#16338)) - `[jest-environment, jest-runtime]` Bind `sandboxInjectedGlobals` to the right values when `injectGlobals` is `false`, instead of shifting every one of them by a position ([#16377](jestjs/jest#16377)) - `[jest-environment-node, jest-util]` Only warn about a conflicting `globalsCleanup` mode when one was explicitly configured, and follow the mode that is actually in effect ([#16323](jestjs/jest#16323)) - `[jest-environment-node, jest-util]` Stop resolving lazy globals when setting up an environment, so Node 26's builtin module globals are no longer loaded (and no longer emit their deprecation warnings) for every test file ([#16324](jestjs/jest#16324)) - `[jest-haste-map]` Keep watch mode alive when an outside process briefly makes a file unreadable on Windows, instead of tearing the watcher down on `EPERM` ([#16295](jestjs/jest#16295)) - `[jest-haste-map]` Keep indexing when an outside process holds a file open on Windows, instead of failing the whole crawl on `EPERM` ([#16358](jestjs/jest#16358)) - `[jest-haste-map]` Keep a duplicated manual mock resolving when the file it pointed at is deleted in watch mode ([#16360](jestjs/jest#16360)) - `[jest-haste-map]` Shut the worker farm down when a duplicate manual mock aborts the build under `throwOnModuleCollision` ([#16354](jestjs/jest#16354)) - `[jest-haste-map]` Attach the watchman client's `error` listener before the first command, so a watchman failure falls back to the node crawler instead of crashing on an unhandled `error` event, and always end the client ([#16355](jestjs/jest#16355)) - `[jest-haste-map]` Stop delivering watch events after `WatchmanWatcher` is closed, and route its warnings through the configured console ([#16355](jestjs/jest#16355)) - `[jest-haste-map]` Restore the nested `duplicates` index correctly in `ModuleMap.fromJSON`, so a haste collision reported inside a test worker raises `DuplicateHasteCandidatesError` instead of a `TypeError` ([#16353](jestjs/jest#16353)) - `[jest-haste-map]` Match watched files on a full extension, so `moduleFileExtensions: ['js']` no longer accepts `foo.mjs` ([#16352](jestjs/jest#16352)) - `[jest-haste-map]` Delimit the fields that make up the haste map cache key, so two different option sets cannot hash to the same cache file ([#16352](jestjs/jest#16352)) - `[jest-message-util]` Print the inner errors of an `AggregateError` thrown inside a test ([#16316](jestjs/jest#16316)) - `[jest-message-util]` Indent nested `cause` and `AggregateError` sections of a test failure by one level per depth, so the nesting is legible instead of rendering flat ([#16316](jestjs/jest#16316)) - `[jest-message-util]` Color stack traces line by line so blank lines stay blank ([#16316](jestjs/jest#16316)) - `[jest-message-util]` Detect Jest's own frames without assuming the checkout directory's name, and cover `@jest/*` packages, so stack traces and code frames point at user code ([#16326](jestjs/jest#16326)) - `[jest-mock]` `mockResolvedValue` / `mockRejectedValue` now see all overload return types, so a Promise-returning overload survives even when a later overload returns a non-Promise (e.g. `pg.Client['end']`) ([#16237](jestjs/jest#16237)) - `[@jest-environment/jsdom-abstract]` Make `@types/jsdom` a peer dependency ([#16166](jestjs/jest#16166)) - `[jest-mock]` Remove the leftover own accessor descriptor when restoring a `spyOn` of an inherited getter or setter, so the instance keeps reflecting the prototype ([#16226](jestjs/jest#16226)) - `[jest-resolve]` Include `extensionsToTreatAsEsm` in the `shouldLoadAsEsm` cache key, so projects with different extension lists don't read each other's answers ([#16369](jestjs/jest#16369)) - `[jest-resolve]` Make `getModuleIDAsync` build and cache `data:` URI module IDs the same way as `getModuleID` ([#16370](jestjs/jest#16370)) - `[jest-resolve]` Keep the `node:` prefix when resolving a core module asynchronously, so a builtin that only exists prefixed (`node:sea`, `node:sqlite`, `node:test`, `node:test/reporters`) resolves instead of failing as a missing bare package ([#16388](jestjs/jest#16388)) - `[jest-resolve]` Look up manual mocks for `node:` protocol specifiers under the unprefixed name they are stored as ([#16388](jestjs/jest#16388)) - `[jest-resolve]` Apply `moduleNameMapper` consistently to both spellings of core module specifiers (`fs` vs `node:fs`) ([#16390](jestjs/jest#16390)) - `[jest-resolve]` Keep virtual and ordinary mock module IDs isolated across test files ([#16296](jestjs/jest#16296)) - `[jest-resolve]` Guard missing `require.resolve.paths` ([#16052](jestjs/jest#16052)) - `[jest-resolve, jest-config, jest-runner]` Support a user resolver written as an ES module ([#16332](jestjs/jest#16332)) - `[jest-resolve, jest-runtime]` Throw the CJS parse error for ESM syntax in a `"type": "commonjs"` package or a `.cjs` file instead of loading it as ESM, matching Node ([#16368](jestjs/jest#16368)) - `[@jest/source-map]` Keep source map sources that name a scheme, such as `webpack:///`, instead of resolving them into a path that does not exist ([#16327](jestjs/jest#16327)) - `[@jest/source-map]` Look up `--testLocationInResults` positions at the right column, and keep a mapping to the first column instead of discarding it ([#16327](jestjs/jest#16327)) - `[@jest/source-map]` Warn when a source map cannot be parsed, instead of silently leaving its frames untranslated ([#16327](jestjs/jest#16327)) - `[jest-runner, @jest/source-map]` Keep a source-mapped stack for an error thrown after the test environment was torn down ([#16327](jestjs/jest#16327)) - `[jest-runtime, @jest/source-map]` Keep source maps past teardown and past the next test file's `install`, so a stack from a file no earlier stack mentioned still points at the original source ([#16330](jestjs/jest#16330)) - `[jest-runtime]` Report that no coverage was collected when `getAllV8CoverageInfoCopy` is called after `teardown`, instead of returning an empty result ([#16385](jestjs/jest#16385)) - `[jest-runtime]` Cache a CJS module's parsed exports before walking its re-exports, so two modules that re-export each other no longer overflow the stack when imported from ESM ([#16363](jestjs/jest#16363)) - `[jest-runtime]` Keep a re-exported ES module's parse failure from marking the re-exporting CommonJS file as ESM, so `module.exports = require('./dep.mjs')` loads instead of failing with `module is not defined` ([#16363](jestjs/jest#16363)) - `[jest-runtime]` Scope module mocks instantiated inside `jest.isolateModules`/`isolateModulesAsync` to that block, so a mock first imported there no longer outlives it - matching how CommonJS mocks already behave ([#16365](jestjs/jest#16365)) - `[jest-runtime]` Suspend module isolation while generating an automock, so loading the real module to read its shape no longer populates the isolated registry ([#16365](jestjs/jest#16365)) - `[jest-runtime]` Check a cached ES module's status before `require()` returns it, so a module whose evaluation threw rethrows that error and one left linked by a failed sibling is evaluated instead of returning uninitialized bindings ([#16364](jestjs/jest#16364)) - `[jest-runtime]` Report the original `ERR_REQUIRE_ASYNC_MODULE` when a `require()` of a top-level-await graph is retried, instead of a spurious "concurrent `import()`" error ([#16364](jestjs/jest#16364)) - `[jest-runtime]` Throw the evaluation error when another caller's `import()` of the same module failed while we awaited it, instead of resolving with the errored module ([#16364](jestjs/jest#16364)) - `[jest-runtime]` Mark the result of `require()`ing an ES module that has a default export with `__esModule: true` through a live-binding facade, and serve the same object from `require.cache`, matching Node ([#16367](jestjs/jest#16367)) - `[jest-runtime]` Provide a CommonJS module's exports under the `'module.exports'` named export when imported from ESM, matching Node 23+ ([#16367](jestjs/jest#16367)) - `[jest-runtime]` Give the test file itself a non-null `require.main` ([#16367](jestjs/jest#16367)) - `[jest-runtime]` Populate `module.children` with the modules a file loads, matching Node ([#16368](jestjs/jest#16368)) - `[jest-runtime]` Provide `import.meta.resolve` and `import.meta.jest` in `data:` URI modules, accept any-case mediatype parameters, and use Node's error codes for invalid `data:` URIs ([#16368](jestjs/jest#16368)) - `[jest-runtime]` Key ES modules by full URL, so query and fragment suffixes create the same module instances as Node and show up in `import.meta.url` ([#16375](jestjs/jest#16375)) - `[jest-runtime]` Share modules between overlapping graphs when a CommonJS module `require()`s an ES module mid-load, instead of evaluating shared dependencies twice ([#16375](jestjs/jest#16375)) - `[jest-runtime]` Throw `ERR_REQUIRE_CYCLE_MODULE` like Node when a CommonJS module `require()`s an ES module that is still being loaded, instead of evaluating the module a second time ([#16366](jestjs/jest#16366)) - `[jest-runtime]` Key builtin modules in the ESM registry by one canonical specifier ([#16341](jestjs/jest#16341)) - `[jest-runtime]` `import.meta.resolve()` for a builtin uses its `node:` specifier ([#16341](jestjs/jest#16341)) - `[jest-runtime]` Fall back to native ESM when a `.js` file contains ESM syntax but has no `"type":"module"` marker ([#16152](jestjs/jest#16152)) - `[jest-runtime]` Allow `require()` of ESM-marked files on Node < 24.9 via transform fallback ([#16244](jestjs/jest#16244)) - `[jest-runtime, @jest/transform]` Surface actionable `ERR_REQUIRE_ESM` error for files with untransformed ESM syntax instead of the generic "unexpected token" message ([#16244](jestjs/jest#16244)) - `[jest-runtime]` Support older test environments whose `moduleMocker` does not implement `clearMocksOnScope` ([#16169](jestjs/jest#16169)) - `[jest-runtime]` Apply `jest.unstable_mockModule` when the mocked file itself is `require()`d, not only when it is imported as a dependency ([#16389](jestjs/jest#16389)) - `[jest-runtime]` Apply `jest.unstable_mockModule` to statically imported `data:` URIs on Node 24.9+, matching dynamic `import()` ([#16389](jestjs/jest#16389)) - `[jest-runtime]` Run an async `jest.unstable_mockModule` factory once per module instead of twice, and fail the import instead of crashing the worker when the factory rejects ([#16389](jestjs/jest#16389)) - `[jest-runtime]` Hide a `require(esm)` module that failed to evaluate from `require.cache`, as Node does, instead of exposing a namespace with uninitialized bindings ([#16389](jestjs/jest#16389)) - `[jest-runtime]` Strip the byte-order mark when importing a JSON module, matching `require()` and Node ([#16389](jestjs/jest#16389)) - `[jest-runtime]` Throw `ERR_REQUIRE_ASYNC_MODULE` when `require(esm)` runs under an async-only custom resolver, instead of silently resolving with the default resolver ([#16389](jestjs/jest#16389)) - `[jest-runtime]` Parse imported JSON modules with the test realm's `JSON`, so their objects pass `instanceof Object` inside the test like `require()`d JSON does ([#16389](jestjs/jest#16389)) - `[jest-runtime]` Accept every `file:` URL string in the sandboxed `module.createRequire`, including one with a `localhost` authority, as Node does ([#16389](jestjs/jest#16389)) - `[jest-runtime]` Point at `{virtual: true}` when `jest.mock` or `jest.unstable_mockModule` is given a module that cannot be resolved ([#16389](jestjs/jest#16389)) - `[jest-reporters]` Fix coverage report table formatting in CI/GitHub Actions environments where `process.stdout.columns` is undefined by falling back to the `COLUMNS` env var or `80` columns in CI, preserving existing behaviour in other non-TTY environments ([#16227](jestjs/jest#16227)) - `[jest-runtime]` Support CJS-in-ESM exports via `"module.exports"` named exports ([#16277](jestjs/jest#16277)) - `[jest-snapshot]` Keep a skipped or failed test's hinted snapshots, instead of reporting them obsolete ([#16348](jestjs/jest#16348)) - `[jest-util]` Stop `globsToMatcher` reusing a cached matcher compiled with different picomatch options, and keep its `dot: true` default when `dot` is passed as `undefined` ([#16381](jestjs/jest#16381)) - `[pretty-format]` Move the `react-is` aliases into the `@jest` scope, so they cannot be shadowed by unrelated packages published under the alias names ([#16333](jestjs/jest#16333)) ##### Chore & Maintenance - `[docs]` Document the intentional divergences from Node's module system in the ECMAScript Modules page ([#16368](jestjs/jest#16368)) - `[docs]` Note deprecation of `react-test-renderer` in React Native tutorial and `pretty-format` README ([#16294](jestjs/jest#16294)) - `[docs]` Use `@testing-library/react-native` in the React Native tutorial instead of the deprecated `react-test-renderer` ([#16318](jestjs/jest#16318)) - `[babel-jest, @jest/transform]` Update `babel-plugin-istanbul` to v8 ([#16049](jestjs/jest#16049)) - `[jest-config, @jest/reporters, jest-runtime]` Update `glob` to v13 ([#16397](jestjs/jest#16397)) - `[jest-haste-map]` Refactor massive class into multiple files ([#16180](jestjs/jest#16180)) - `[jest-haste-map]` Drop `walker` dependency; replace hand-rolled directory recursion in the JS crawler and watcher startup with `fdir` ([#16187](jestjs/jest#16187)) - `[jest-haste-map]` Reuse cached metadata for files whose haste name is a known duplicate, instead of re-reading and re-parsing them on every startup ([#16351](jestjs/jest#16351)) - `[jest-haste-map]` Cache the watchman socket path and replace the `watchman --version` probe with `get-sockname`, so warm runs spawn no watchman processes ([#16386](jestjs/jest#16386)) - `[jest-resolve]` Store the per-directory package-type lookup in the cache it reads, so it actually memoizes ([#16369](jestjs/jest#16369)) - `[jest-resolve, jest-runtime]` Cut repeated work on the resolution hot path: hoist the platform-extension list to construction, memoize `isCoreModule` and the options cache-key serialization, skip mapper preparation when no `moduleNameMapper` is configured, run each mapper regex once, and stop re-parsing `NODE_OPTIONS` on every default-resolver call ([#16371](jestjs/jest#16371)) - `[jest-resolve]` Cut warm resolution cost to about a third: reuse one `unrs-resolver` factory per options shape instead of cloning per resolution, compose the factory cache key from per-array cached strings instead of serializing options, and stop constructing an `Error` for misses that `findNodeModule` swallows; add a `__benchmarks__` suite for the default resolver ([#16373](jestjs/jest#16373)) - `[jest-runner, @jest/source-map]` Replace `source-map-support` with an implementation in `@jest/source-map` ([#16327](jestjs/jest#16327)) - `[jest-snapshot]` Load babel, semver and synckit lazily, so requiring the package (which every test process does through `@jest/expect`) no longer loads \~200 modules that only writing inline snapshots needs ([#16387](jestjs/jest#16387)) - `[jest-runtime]` Reduce per-require overhead: skip module ID resolution when no mock can apply, answer core modules before probing for a manual mock, share one `require.cache` proxy across modules, and cache empty files ([#16376](jestjs/jest#16376)) - `[@jest/source-map]` Deprecate `getCallsite` in favour of `SourceMapSupport#getCallsite` ([#16327](jestjs/jest#16327)) - `[jest-runtime]` Avoid magical `null` value in ESM loader ([#16160](jestjs/jest#16160))
| datasource | package | from | to | | ---------- | ------- | ------ | ------ | | npm | jest | 30.4.2 | 30.5.1 | ## [v30.5.1](https://github.com/jestjs/jest/blob/HEAD/CHANGELOG.md#3051) ##### Fixes - `[jest-config]` Don't warn about global-only options in the config that supplies the global config - the root config a project resolves to, or the first entry of `--projects` when no root config is passed ([#16411](jestjs/jest#16411)) - `[jest-config, jest-types]` Stop accepting `reporters`, `coverageReporters`, `workerIdleMemoryLimit`, `cwd` and `runnerOptions` in a project config - they were silently ignored, and now warn like the other global-only options ([#16411](jestjs/jest#16411)) - `[jest-config, jest-validate]` Warn about `maxWorkers` and `coverageThreshold` in a project config instead of dropping them without a word ([#16411](jestjs/jest#16411)) - `[jest-resolve]` Match `moduleNameMapper` patterns against the specifier as written again (reverting [#16390](jestjs/jest#16390)) ([#16417](jestjs/jest#16417)) - `[jest-runtime]` Resolve package `imports` specifiers like `#dep` under ESM again ([#16413](jestjs/jest#16413)) ##### Chore & Maintenance - `[jest-util]` Name the `testEnvironmentOptions.globalsCleanup` option and link the docs from the `JEST-01` deprecation warning, and document the option's modes ([#16404](jestjs/jest#16404)) ## [v30.5.0](https://github.com/jestjs/jest/blob/HEAD/CHANGELOG.md#3050) ##### Features - `[@jest/expect-utils, jest-mock]` Add `mockFn.whenCalledWith(...args)` for configuring return values per argument list, with first-class asymmetric-matcher support ([#16053](jestjs/jest#16053)) - `[@jest/expect-utils]` Export `AsymmetricMatcher` and `FunctionParameters` types (previously private to `expect`) ([#16053](jestjs/jest#16053)) - `[jest-circus, jest-core, jest-jasmine2, jest-test-result, jest-types]` `--collectTests` now expands `test.each`/`describe.each` cases and reports per-status counts (skipped/todo via the new `wouldRun` flag for selected tests) plus a summary line that match a real run, including under `--testNamePattern` and `.only`/`fdescribe` focus on both the circus and jasmine2 runners ([#16259](jestjs/jest#16259)) - `[jest-circus, jest-environment, jest-runtime, jest-types]` Add describe-level retries via `jest.retryTimes(..., {entireDescribe: true})` ([#16322](jestjs/jest#16322)) - `[jest-circus, jest-message-util, jest-reporters, jest-types]` Add `retryMessages` to `AssertionResult` and export `formatErrorStack`, so the retry log renders nested `cause` and `AggregateError` sections with code frames instead of serialized `[cause]:`/`[errors]:` markers ([#16316](jestjs/jest#16316)) - `[jest-circus, jest-types]` Add `unhandledErrorsDetailed` to `Circus.RunResult`, so an unhandled rejection reports its `cause` chain and `AggregateError` entries with code frames instead of a pre-serialized stack ([#16316](jestjs/jest#16316)) - `[jest-haste-map]` Replace `NodeWatcher` and `FSEventsWatcher` with `@parcel/watcher` for the non-watchman watch path ([#16188](jestjs/jest#16188)) - `[jest-resolve]` Bump `unrs-resolver` to 1.12.1, remove `jest-pnp-resolver` and unnecessary checks ([#15721](jestjs/jest#15721)) - `[jest-resolve]` Honor Node's `--preserve-symlinks` / `NODE_PRESERVE_SYMLINKS` in the default resolver by passing `symlinks: false` to `unrs-resolver` ([#16260](jestjs/jest#16260)) - `[jest-runtime]` Apply automocking and manual `__mocks__` files to synchronously evaluable ESM graphs on Node 24.9+ - static imports, dynamic `import()` and `require()` of an ESM file now generate an automock from the real module's namespace instead of failing with "Attempting to import a mock without a factory". Graphs that need async evaluation (top-level await) or an async-only resolver or transformer still throw ([#16391](jestjs/jest#16391)) - `[jest-runtime]` Route `process.getBuiltinModule` through the sandbox, so it returns the sandbox `process` and the hooked `node:module` instead of the host's ([#16391](jestjs/jest#16391)) - `[jest-runtime]` Throw an actionable error from `module.register()` and `module.registerHooks()` inside a test - the hooks attached to the loader running Jest itself, never saw the sandboxed requires they were meant for, and stayed registered for every later test file in the worker ([#16391](jestjs/jest#16391)) - `[jest-runtime]` Surface resolution and import-attribute errors in an ESM graph before executing any of its CJS dependencies on Node 24.9+, matching Node's run-nothing-on-a-broken-graph behavior; the legacy loader on older versions keeps its linking-time execution order ([#16391](jestjs/jest#16391)) - `[jest-runtime]` Throw `ERR_SOURCE_PHASE_NOT_DEFINED` with an actionable message for `import source` and `import.source()`, instead of failing at instantiation with V8's bare "Source phase import object is not defined" ([#16391](jestjs/jest#16391)) - `[jest-runtime]` Emit the JSON-without-import-attribute deprecation warning once per test file instead of once per worker, so it is no longer silently swallowed for every file after the first ([#16391](jestjs/jest#16391)) - `[jest-runtime]` Set `import.meta.main` to `true` in the test file and `false` in every module it loads, matching Node 24+ ([#16367](jestjs/jest#16367)) - `[jest-runtime]` Resolve the `module-sync` export condition, so a package that exposes its ESM entry point for `require()` loads the same file Node would ([#16336](jestjs/jest#16336)) - `[jest-snapshot]` Add external snapshot paths to custom reporter failure details ([#16374](jestjs/jest#16374)) ##### Fixes - `[jest-console, jest-reporters]` `CustomConsole` now buffers console output so `TestResult.console` is populated for reporters when `verbose` is enabled, while `GitHubActionsReporter` avoids replaying buffered output in verbose mode ([#16155](jestjs/jest#16155)) - `[expect, jest-message-util, jest-pattern, jest-regex-util, jest-util]` Revert `node:` protocol imports to restore webpack/browser-bundle compatibility ([#16167](jestjs/jest#16167)) - `[expect]` Widen `toMatchObject` and `objectContaining` parameter type from `Record<string, unknown>` to `object` so class instances are accepted ([#16196](jestjs/jest#16196)) - `[jest-circus]` Call a generator test body with the shared test context, so `this` matches what a regular test function receives ([#16347](jestjs/jest#16347)) - `[jest-circus]` Capture the error listeners of the parent process instead of the in-sandbox `process`, so listeners registered before the test file survive teardown and sandbox listeners no longer leak onto the parent ([#16347](jestjs/jest#16347)) - `[jest-circus]` Clear `currentlyRunningTest` after skipped and todo tests ([#16342](jestjs/jest#16342)) - `[jest-circus]` Prevent late `done()` callbacks from affecting later test or hook invocations ([#16343](jestjs/jest#16343)) - `[jest-circus, jest-jasmine2]` Honor `--expand` when formatting `node:assert` failures, instead of always collapsing the diff ([#16347](jestjs/jest#16347)) - `[jest-circus, jest-jasmine2, jest-message-util]` Serialize the inner errors of an `AggregateError` into `failureMessages`, `retryReasons` and `unhandledErrors`, so `--json` output and reporter annotations include them ([#16316](jestjs/jest#16316)) - `[jest-circus, jest-snapshot]` Keep snapshot state and counts correct when a test retries ([#16344](jestjs/jest#16344)) - `[@jest/create-cache-key-function]` Include the caller support flags in the generated key, so a transformer that emits ESM or CJS based on them no longer shares one cache entry between the two ([#16331](jestjs/jest#16331)) - `[@jest/create-cache-key-function]` Include the stringified project config in the generated key, so editing a transformer's own settings invalidates what it cached ([#16331](jestjs/jest#16331)) - `[@jest/transform]` Include the caller support flags in a transform's cache key, so a file transformed both as ESM and as CJS no longer serves one shape's output for the other ([#16331](jestjs/jest#16331)) - `[jest-config]` Add missing `findRelatedTests`, `outputFile`, and `replname` entries to `ValidConfig` so they no longer trigger spurious "Unknown option" warnings ([#16224](jestjs/jest#16224)) - `[jest-config]` Use `--config` for the global config when multiple `--projects` are specified ([#16273](jestjs/jest#16273)) - `[jest-core]` Serialize `bigint` values in `--json` and `--outputFile` output as their literal form (`4n`), instead of failing the run with `TypeError: Do not know how to serialize a BigInt` ([#16338](jestjs/jest#16338)) - `[jest-core]` Do not report a `CustomGC` async resource (used by N-API addons such as napi-rs for per-isolate GC bookkeeping) as an open handle, since it is `napi_unref`'d by the addon and can never keep the event loop alive ([#16379](jestjs/jest#16379)) - `[jest-each]` Keep a `$&`, `` $` ``, `$'` or `$$` inside a `%p` param value out of the replacement, so the title shows the value instead of the text around it ([#16338](jestjs/jest#16338)) - `[jest-each]` Interpolate a `bigint` into a `%j` title as its literal form (`"4n"`) at any depth, instead of throwing `TypeError: Do not know how to serialize a BigInt` while collecting the tests ([#16338](jestjs/jest#16338)) - `[jest-environment, jest-runtime]` Bind `sandboxInjectedGlobals` to the right values when `injectGlobals` is `false`, instead of shifting every one of them by a position ([#16377](jestjs/jest#16377)) - `[jest-environment-node, jest-util]` Only warn about a conflicting `globalsCleanup` mode when one was explicitly configured, and follow the mode that is actually in effect ([#16323](jestjs/jest#16323)) - `[jest-environment-node, jest-util]` Stop resolving lazy globals when setting up an environment, so Node 26's builtin module globals are no longer loaded (and no longer emit their deprecation warnings) for every test file ([#16324](jestjs/jest#16324)) - `[jest-haste-map]` Keep watch mode alive when an outside process briefly makes a file unreadable on Windows, instead of tearing the watcher down on `EPERM` ([#16295](jestjs/jest#16295)) - `[jest-haste-map]` Keep indexing when an outside process holds a file open on Windows, instead of failing the whole crawl on `EPERM` ([#16358](jestjs/jest#16358)) - `[jest-haste-map]` Keep a duplicated manual mock resolving when the file it pointed at is deleted in watch mode ([#16360](jestjs/jest#16360)) - `[jest-haste-map]` Shut the worker farm down when a duplicate manual mock aborts the build under `throwOnModuleCollision` ([#16354](jestjs/jest#16354)) - `[jest-haste-map]` Attach the watchman client's `error` listener before the first command, so a watchman failure falls back to the node crawler instead of crashing on an unhandled `error` event, and always end the client ([#16355](jestjs/jest#16355)) - `[jest-haste-map]` Stop delivering watch events after `WatchmanWatcher` is closed, and route its warnings through the configured console ([#16355](jestjs/jest#16355)) - `[jest-haste-map]` Restore the nested `duplicates` index correctly in `ModuleMap.fromJSON`, so a haste collision reported inside a test worker raises `DuplicateHasteCandidatesError` instead of a `TypeError` ([#16353](jestjs/jest#16353)) - `[jest-haste-map]` Match watched files on a full extension, so `moduleFileExtensions: ['js']` no longer accepts `foo.mjs` ([#16352](jestjs/jest#16352)) - `[jest-haste-map]` Delimit the fields that make up the haste map cache key, so two different option sets cannot hash to the same cache file ([#16352](jestjs/jest#16352)) - `[jest-message-util]` Print the inner errors of an `AggregateError` thrown inside a test ([#16316](jestjs/jest#16316)) - `[jest-message-util]` Indent nested `cause` and `AggregateError` sections of a test failure by one level per depth, so the nesting is legible instead of rendering flat ([#16316](jestjs/jest#16316)) - `[jest-message-util]` Color stack traces line by line so blank lines stay blank ([#16316](jestjs/jest#16316)) - `[jest-message-util]` Detect Jest's own frames without assuming the checkout directory's name, and cover `@jest/*` packages, so stack traces and code frames point at user code ([#16326](jestjs/jest#16326)) - `[jest-mock]` `mockResolvedValue` / `mockRejectedValue` now see all overload return types, so a Promise-returning overload survives even when a later overload returns a non-Promise (e.g. `pg.Client['end']`) ([#16237](jestjs/jest#16237)) - `[@jest-environment/jsdom-abstract]` Make `@types/jsdom` a peer dependency ([#16166](jestjs/jest#16166)) - `[jest-mock]` Remove the leftover own accessor descriptor when restoring a `spyOn` of an inherited getter or setter, so the instance keeps reflecting the prototype ([#16226](jestjs/jest#16226)) - `[jest-resolve]` Include `extensionsToTreatAsEsm` in the `shouldLoadAsEsm` cache key, so projects with different extension lists don't read each other's answers ([#16369](jestjs/jest#16369)) - `[jest-resolve]` Make `getModuleIDAsync` build and cache `data:` URI module IDs the same way as `getModuleID` ([#16370](jestjs/jest#16370)) - `[jest-resolve]` Keep the `node:` prefix when resolving a core module asynchronously, so a builtin that only exists prefixed (`node:sea`, `node:sqlite`, `node:test`, `node:test/reporters`) resolves instead of failing as a missing bare package ([#16388](jestjs/jest#16388)) - `[jest-resolve]` Look up manual mocks for `node:` protocol specifiers under the unprefixed name they are stored as ([#16388](jestjs/jest#16388)) - `[jest-resolve]` Apply `moduleNameMapper` consistently to both spellings of core module specifiers (`fs` vs `node:fs`) ([#16390](jestjs/jest#16390)) - `[jest-resolve]` Keep virtual and ordinary mock module IDs isolated across test files ([#16296](jestjs/jest#16296)) - `[jest-resolve]` Guard missing `require.resolve.paths` ([#16052](jestjs/jest#16052)) - `[jest-resolve, jest-config, jest-runner]` Support a user resolver written as an ES module ([#16332](jestjs/jest#16332)) - `[jest-resolve, jest-runtime]` Throw the CJS parse error for ESM syntax in a `"type": "commonjs"` package or a `.cjs` file instead of loading it as ESM, matching Node ([#16368](jestjs/jest#16368)) - `[@jest/source-map]` Keep source map sources that name a scheme, such as `webpack:///`, instead of resolving them into a path that does not exist ([#16327](jestjs/jest#16327)) - `[@jest/source-map]` Look up `--testLocationInResults` positions at the right column, and keep a mapping to the first column instead of discarding it ([#16327](jestjs/jest#16327)) - `[@jest/source-map]` Warn when a source map cannot be parsed, instead of silently leaving its frames untranslated ([#16327](jestjs/jest#16327)) - `[jest-runner, @jest/source-map]` Keep a source-mapped stack for an error thrown after the test environment was torn down ([#16327](jestjs/jest#16327)) - `[jest-runtime, @jest/source-map]` Keep source maps past teardown and past the next test file's `install`, so a stack from a file no earlier stack mentioned still points at the original source ([#16330](jestjs/jest#16330)) - `[jest-runtime]` Report that no coverage was collected when `getAllV8CoverageInfoCopy` is called after `teardown`, instead of returning an empty result ([#16385](jestjs/jest#16385)) - `[jest-runtime]` Cache a CJS module's parsed exports before walking its re-exports, so two modules that re-export each other no longer overflow the stack when imported from ESM ([#16363](jestjs/jest#16363)) - `[jest-runtime]` Keep a re-exported ES module's parse failure from marking the re-exporting CommonJS file as ESM, so `module.exports = require('./dep.mjs')` loads instead of failing with `module is not defined` ([#16363](jestjs/jest#16363)) - `[jest-runtime]` Scope module mocks instantiated inside `jest.isolateModules`/`isolateModulesAsync` to that block, so a mock first imported there no longer outlives it - matching how CommonJS mocks already behave ([#16365](jestjs/jest#16365)) - `[jest-runtime]` Suspend module isolation while generating an automock, so loading the real module to read its shape no longer populates the isolated registry ([#16365](jestjs/jest#16365)) - `[jest-runtime]` Check a cached ES module's status before `require()` returns it, so a module whose evaluation threw rethrows that error and one left linked by a failed sibling is evaluated instead of returning uninitialized bindings ([#16364](jestjs/jest#16364)) - `[jest-runtime]` Report the original `ERR_REQUIRE_ASYNC_MODULE` when a `require()` of a top-level-await graph is retried, instead of a spurious "concurrent `import()`" error ([#16364](jestjs/jest#16364)) - `[jest-runtime]` Throw the evaluation error when another caller's `import()` of the same module failed while we awaited it, instead of resolving with the errored module ([#16364](jestjs/jest#16364)) - `[jest-runtime]` Mark the result of `require()`ing an ES module that has a default export with `__esModule: true` through a live-binding facade, and serve the same object from `require.cache`, matching Node ([#16367](jestjs/jest#16367)) - `[jest-runtime]` Provide a CommonJS module's exports under the `'module.exports'` named export when imported from ESM, matching Node 23+ ([#16367](jestjs/jest#16367)) - `[jest-runtime]` Give the test file itself a non-null `require.main` ([#16367](jestjs/jest#16367)) - `[jest-runtime]` Populate `module.children` with the modules a file loads, matching Node ([#16368](jestjs/jest#16368)) - `[jest-runtime]` Provide `import.meta.resolve` and `import.meta.jest` in `data:` URI modules, accept any-case mediatype parameters, and use Node's error codes for invalid `data:` URIs ([#16368](jestjs/jest#16368)) - `[jest-runtime]` Key ES modules by full URL, so query and fragment suffixes create the same module instances as Node and show up in `import.meta.url` ([#16375](jestjs/jest#16375)) - `[jest-runtime]` Share modules between overlapping graphs when a CommonJS module `require()`s an ES module mid-load, instead of evaluating shared dependencies twice ([#16375](jestjs/jest#16375)) - `[jest-runtime]` Throw `ERR_REQUIRE_CYCLE_MODULE` like Node when a CommonJS module `require()`s an ES module that is still being loaded, instead of evaluating the module a second time ([#16366](jestjs/jest#16366)) - `[jest-runtime]` Key builtin modules in the ESM registry by one canonical specifier ([#16341](jestjs/jest#16341)) - `[jest-runtime]` `import.meta.resolve()` for a builtin uses its `node:` specifier ([#16341](jestjs/jest#16341)) - `[jest-runtime]` Fall back to native ESM when a `.js` file contains ESM syntax but has no `"type":"module"` marker ([#16152](jestjs/jest#16152)) - `[jest-runtime]` Allow `require()` of ESM-marked files on Node < 24.9 via transform fallback ([#16244](jestjs/jest#16244)) - `[jest-runtime, @jest/transform]` Surface actionable `ERR_REQUIRE_ESM` error for files with untransformed ESM syntax instead of the generic "unexpected token" message ([#16244](jestjs/jest#16244)) - `[jest-runtime]` Support older test environments whose `moduleMocker` does not implement `clearMocksOnScope` ([#16169](jestjs/jest#16169)) - `[jest-runtime]` Apply `jest.unstable_mockModule` when the mocked file itself is `require()`d, not only when it is imported as a dependency ([#16389](jestjs/jest#16389)) - `[jest-runtime]` Apply `jest.unstable_mockModule` to statically imported `data:` URIs on Node 24.9+, matching dynamic `import()` ([#16389](jestjs/jest#16389)) - `[jest-runtime]` Run an async `jest.unstable_mockModule` factory once per module instead of twice, and fail the import instead of crashing the worker when the factory rejects ([#16389](jestjs/jest#16389)) - `[jest-runtime]` Hide a `require(esm)` module that failed to evaluate from `require.cache`, as Node does, instead of exposing a namespace with uninitialized bindings ([#16389](jestjs/jest#16389)) - `[jest-runtime]` Strip the byte-order mark when importing a JSON module, matching `require()` and Node ([#16389](jestjs/jest#16389)) - `[jest-runtime]` Throw `ERR_REQUIRE_ASYNC_MODULE` when `require(esm)` runs under an async-only custom resolver, instead of silently resolving with the default resolver ([#16389](jestjs/jest#16389)) - `[jest-runtime]` Parse imported JSON modules with the test realm's `JSON`, so their objects pass `instanceof Object` inside the test like `require()`d JSON does ([#16389](jestjs/jest#16389)) - `[jest-runtime]` Accept every `file:` URL string in the sandboxed `module.createRequire`, including one with a `localhost` authority, as Node does ([#16389](jestjs/jest#16389)) - `[jest-runtime]` Point at `{virtual: true}` when `jest.mock` or `jest.unstable_mockModule` is given a module that cannot be resolved ([#16389](jestjs/jest#16389)) - `[jest-reporters]` Fix coverage report table formatting in CI/GitHub Actions environments where `process.stdout.columns` is undefined by falling back to the `COLUMNS` env var or `80` columns in CI, preserving existing behaviour in other non-TTY environments ([#16227](jestjs/jest#16227)) - `[jest-runtime]` Support CJS-in-ESM exports via `"module.exports"` named exports ([#16277](jestjs/jest#16277)) - `[jest-snapshot]` Keep a skipped or failed test's hinted snapshots, instead of reporting them obsolete ([#16348](jestjs/jest#16348)) - `[jest-util]` Stop `globsToMatcher` reusing a cached matcher compiled with different picomatch options, and keep its `dot: true` default when `dot` is passed as `undefined` ([#16381](jestjs/jest#16381)) - `[pretty-format]` Move the `react-is` aliases into the `@jest` scope, so they cannot be shadowed by unrelated packages published under the alias names ([#16333](jestjs/jest#16333)) ##### Chore & Maintenance - `[docs]` Document the intentional divergences from Node's module system in the ECMAScript Modules page ([#16368](jestjs/jest#16368)) - `[docs]` Note deprecation of `react-test-renderer` in React Native tutorial and `pretty-format` README ([#16294](jestjs/jest#16294)) - `[docs]` Use `@testing-library/react-native` in the React Native tutorial instead of the deprecated `react-test-renderer` ([#16318](jestjs/jest#16318)) - `[babel-jest, @jest/transform]` Update `babel-plugin-istanbul` to v8 ([#16049](jestjs/jest#16049)) - `[jest-config, @jest/reporters, jest-runtime]` Update `glob` to v13 ([#16397](jestjs/jest#16397)) - `[jest-haste-map]` Refactor massive class into multiple files ([#16180](jestjs/jest#16180)) - `[jest-haste-map]` Drop `walker` dependency; replace hand-rolled directory recursion in the JS crawler and watcher startup with `fdir` ([#16187](jestjs/jest#16187)) - `[jest-haste-map]` Reuse cached metadata for files whose haste name is a known duplicate, instead of re-reading and re-parsing them on every startup ([#16351](jestjs/jest#16351)) - `[jest-haste-map]` Cache the watchman socket path and replace the `watchman --version` probe with `get-sockname`, so warm runs spawn no watchman processes ([#16386](jestjs/jest#16386)) - `[jest-resolve]` Store the per-directory package-type lookup in the cache it reads, so it actually memoizes ([#16369](jestjs/jest#16369)) - `[jest-resolve, jest-runtime]` Cut repeated work on the resolution hot path: hoist the platform-extension list to construction, memoize `isCoreModule` and the options cache-key serialization, skip mapper preparation when no `moduleNameMapper` is configured, run each mapper regex once, and stop re-parsing `NODE_OPTIONS` on every default-resolver call ([#16371](jestjs/jest#16371)) - `[jest-resolve]` Cut warm resolution cost to about a third: reuse one `unrs-resolver` factory per options shape instead of cloning per resolution, compose the factory cache key from per-array cached strings instead of serializing options, and stop constructing an `Error` for misses that `findNodeModule` swallows; add a `__benchmarks__` suite for the default resolver ([#16373](jestjs/jest#16373)) - `[jest-runner, @jest/source-map]` Replace `source-map-support` with an implementation in `@jest/source-map` ([#16327](jestjs/jest#16327)) - `[jest-snapshot]` Load babel, semver and synckit lazily, so requiring the package (which every test process does through `@jest/expect`) no longer loads \~200 modules that only writing inline snapshots needs ([#16387](jestjs/jest#16387)) - `[jest-runtime]` Reduce per-require overhead: skip module ID resolution when no mock can apply, answer core modules before probing for a manual mock, share one `require.cache` proxy across modules, and cache empty files ([#16376](jestjs/jest#16376)) - `[@jest/source-map]` Deprecate `getCallsite` in favour of `SourceMapSupport#getCallsite` ([#16327](jestjs/jest#16327)) - `[jest-runtime]` Avoid magical `null` value in ESM loader ([#16160](jestjs/jest#16160))
jest-haste-map 30.5 depends on @parcel/watcher, whose install script pnpm rejects as an unapproved build. The script only compiles when npm_config_build_from_source is set, so deny it and use the prebuilt binary. Jest 30.5 throws when loaded code calls module.register/registerHooks (jestjs/jest#16391), and @tailwindcss/node does so on import, so the globals.css suite failed to run. Hide both registrars from that suite only; the hook just busts the ESM cache on plugin reloads, which a one-shot compile never does. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01D1LFFck4v6conaihBc2zYh
| datasource | package | from | to | | ---------- | ---------------------- | ------ | ------ | | npm | jest | 30.4.2 | 30.5.1 | | npm | jest-environment-jsdom | 30.4.1 | 30.5.1 | ## [v30.5.1](https://github.com/jestjs/jest/blob/HEAD/CHANGELOG.md#3051) ##### Fixes - `[jest-config]` Don't warn about global-only options in the config that supplies the global config - the root config a project resolves to, or the first entry of `--projects` when no root config is passed ([#16411](jestjs/jest#16411)) - `[jest-config, jest-types]` Stop accepting `reporters`, `coverageReporters`, `workerIdleMemoryLimit`, `cwd` and `runnerOptions` in a project config - they were silently ignored, and now warn like the other global-only options ([#16411](jestjs/jest#16411)) - `[jest-config, jest-validate]` Warn about `maxWorkers` and `coverageThreshold` in a project config instead of dropping them without a word ([#16411](jestjs/jest#16411)) - `[jest-resolve]` Match `moduleNameMapper` patterns against the specifier as written again (reverting [#16390](jestjs/jest#16390)) ([#16417](jestjs/jest#16417)) - `[jest-runtime]` Resolve package `imports` specifiers like `#dep` under ESM again ([#16413](jestjs/jest#16413)) ##### Chore & Maintenance - `[jest-util]` Name the `testEnvironmentOptions.globalsCleanup` option and link the docs from the `JEST-01` deprecation warning, and document the option's modes ([#16404](jestjs/jest#16404)) ## [v30.5.0](https://github.com/jestjs/jest/blob/HEAD/CHANGELOG.md#3050) ##### Features - `[@jest/expect-utils, jest-mock]` Add `mockFn.whenCalledWith(...args)` for configuring return values per argument list, with first-class asymmetric-matcher support ([#16053](jestjs/jest#16053)) - `[@jest/expect-utils]` Export `AsymmetricMatcher` and `FunctionParameters` types (previously private to `expect`) ([#16053](jestjs/jest#16053)) - `[jest-circus, jest-core, jest-jasmine2, jest-test-result, jest-types]` `--collectTests` now expands `test.each`/`describe.each` cases and reports per-status counts (skipped/todo via the new `wouldRun` flag for selected tests) plus a summary line that match a real run, including under `--testNamePattern` and `.only`/`fdescribe` focus on both the circus and jasmine2 runners ([#16259](jestjs/jest#16259)) - `[jest-circus, jest-environment, jest-runtime, jest-types]` Add describe-level retries via `jest.retryTimes(..., {entireDescribe: true})` ([#16322](jestjs/jest#16322)) - `[jest-circus, jest-message-util, jest-reporters, jest-types]` Add `retryMessages` to `AssertionResult` and export `formatErrorStack`, so the retry log renders nested `cause` and `AggregateError` sections with code frames instead of serialized `[cause]:`/`[errors]:` markers ([#16316](jestjs/jest#16316)) - `[jest-circus, jest-types]` Add `unhandledErrorsDetailed` to `Circus.RunResult`, so an unhandled rejection reports its `cause` chain and `AggregateError` entries with code frames instead of a pre-serialized stack ([#16316](jestjs/jest#16316)) - `[jest-haste-map]` Replace `NodeWatcher` and `FSEventsWatcher` with `@parcel/watcher` for the non-watchman watch path ([#16188](jestjs/jest#16188)) - `[jest-resolve]` Bump `unrs-resolver` to 1.12.1, remove `jest-pnp-resolver` and unnecessary checks ([#15721](jestjs/jest#15721)) - `[jest-resolve]` Honor Node's `--preserve-symlinks` / `NODE_PRESERVE_SYMLINKS` in the default resolver by passing `symlinks: false` to `unrs-resolver` ([#16260](jestjs/jest#16260)) - `[jest-runtime]` Apply automocking and manual `__mocks__` files to synchronously evaluable ESM graphs on Node 24.9+ - static imports, dynamic `import()` and `require()` of an ESM file now generate an automock from the real module's namespace instead of failing with "Attempting to import a mock without a factory". Graphs that need async evaluation (top-level await) or an async-only resolver or transformer still throw ([#16391](jestjs/jest#16391)) - `[jest-runtime]` Route `process.getBuiltinModule` through the sandbox, so it returns the sandbox `process` and the hooked `node:module` instead of the host's ([#16391](jestjs/jest#16391)) - `[jest-runtime]` Throw an actionable error from `module.register()` and `module.registerHooks()` inside a test - the hooks attached to the loader running Jest itself, never saw the sandboxed requires they were meant for, and stayed registered for every later test file in the worker ([#16391](jestjs/jest#16391)) - `[jest-runtime]` Surface resolution and import-attribute errors in an ESM graph before executing any of its CJS dependencies on Node 24.9+, matching Node's run-nothing-on-a-broken-graph behavior; the legacy loader on older versions keeps its linking-time execution order ([#16391](jestjs/jest#16391)) - `[jest-runtime]` Throw `ERR_SOURCE_PHASE_NOT_DEFINED` with an actionable message for `import source` and `import.source()`, instead of failing at instantiation with V8's bare "Source phase import object is not defined" ([#16391](jestjs/jest#16391)) - `[jest-runtime]` Emit the JSON-without-import-attribute deprecation warning once per test file instead of once per worker, so it is no longer silently swallowed for every file after the first ([#16391](jestjs/jest#16391)) - `[jest-runtime]` Set `import.meta.main` to `true` in the test file and `false` in every module it loads, matching Node 24+ ([#16367](jestjs/jest#16367)) - `[jest-runtime]` Resolve the `module-sync` export condition, so a package that exposes its ESM entry point for `require()` loads the same file Node would ([#16336](jestjs/jest#16336)) - `[jest-snapshot]` Add external snapshot paths to custom reporter failure details ([#16374](jestjs/jest#16374)) ##### Fixes - `[jest-console, jest-reporters]` `CustomConsole` now buffers console output so `TestResult.console` is populated for reporters when `verbose` is enabled, while `GitHubActionsReporter` avoids replaying buffered output in verbose mode ([#16155](jestjs/jest#16155)) - `[expect, jest-message-util, jest-pattern, jest-regex-util, jest-util]` Revert `node:` protocol imports to restore webpack/browser-bundle compatibility ([#16167](jestjs/jest#16167)) - `[expect]` Widen `toMatchObject` and `objectContaining` parameter type from `Record<string, unknown>` to `object` so class instances are accepted ([#16196](jestjs/jest#16196)) - `[jest-circus]` Call a generator test body with the shared test context, so `this` matches what a regular test function receives ([#16347](jestjs/jest#16347)) - `[jest-circus]` Capture the error listeners of the parent process instead of the in-sandbox `process`, so listeners registered before the test file survive teardown and sandbox listeners no longer leak onto the parent ([#16347](jestjs/jest#16347)) - `[jest-circus]` Clear `currentlyRunningTest` after skipped and todo tests ([#16342](jestjs/jest#16342)) - `[jest-circus]` Prevent late `done()` callbacks from affecting later test or hook invocations ([#16343](jestjs/jest#16343)) - `[jest-circus, jest-jasmine2]` Honor `--expand` when formatting `node:assert` failures, instead of always collapsing the diff ([#16347](jestjs/jest#16347)) - `[jest-circus, jest-jasmine2, jest-message-util]` Serialize the inner errors of an `AggregateError` into `failureMessages`, `retryReasons` and `unhandledErrors`, so `--json` output and reporter annotations include them ([#16316](jestjs/jest#16316)) - `[jest-circus, jest-snapshot]` Keep snapshot state and counts correct when a test retries ([#16344](jestjs/jest#16344)) - `[@jest/create-cache-key-function]` Include the caller support flags in the generated key, so a transformer that emits ESM or CJS based on them no longer shares one cache entry between the two ([#16331](jestjs/jest#16331)) - `[@jest/create-cache-key-function]` Include the stringified project config in the generated key, so editing a transformer's own settings invalidates what it cached ([#16331](jestjs/jest#16331)) - `[@jest/transform]` Include the caller support flags in a transform's cache key, so a file transformed both as ESM and as CJS no longer serves one shape's output for the other ([#16331](jestjs/jest#16331)) - `[jest-config]` Add missing `findRelatedTests`, `outputFile`, and `replname` entries to `ValidConfig` so they no longer trigger spurious "Unknown option" warnings ([#16224](jestjs/jest#16224)) - `[jest-config]` Use `--config` for the global config when multiple `--projects` are specified ([#16273](jestjs/jest#16273)) - `[jest-core]` Serialize `bigint` values in `--json` and `--outputFile` output as their literal form (`4n`), instead of failing the run with `TypeError: Do not know how to serialize a BigInt` ([#16338](jestjs/jest#16338)) - `[jest-core]` Do not report a `CustomGC` async resource (used by N-API addons such as napi-rs for per-isolate GC bookkeeping) as an open handle, since it is `napi_unref`'d by the addon and can never keep the event loop alive ([#16379](jestjs/jest#16379)) - `[jest-each]` Keep a `$&`, `` $` ``, `$'` or `$$` inside a `%p` param value out of the replacement, so the title shows the value instead of the text around it ([#16338](jestjs/jest#16338)) - `[jest-each]` Interpolate a `bigint` into a `%j` title as its literal form (`"4n"`) at any depth, instead of throwing `TypeError: Do not know how to serialize a BigInt` while collecting the tests ([#16338](jestjs/jest#16338)) - `[jest-environment, jest-runtime]` Bind `sandboxInjectedGlobals` to the right values when `injectGlobals` is `false`, instead of shifting every one of them by a position ([#16377](jestjs/jest#16377)) - `[jest-environment-node, jest-util]` Only warn about a conflicting `globalsCleanup` mode when one was explicitly configured, and follow the mode that is actually in effect ([#16323](jestjs/jest#16323)) - `[jest-environment-node, jest-util]` Stop resolving lazy globals when setting up an environment, so Node 26's builtin module globals are no longer loaded (and no longer emit their deprecation warnings) for every test file ([#16324](jestjs/jest#16324)) - `[jest-haste-map]` Keep watch mode alive when an outside process briefly makes a file unreadable on Windows, instead of tearing the watcher down on `EPERM` ([#16295](jestjs/jest#16295)) - `[jest-haste-map]` Keep indexing when an outside process holds a file open on Windows, instead of failing the whole crawl on `EPERM` ([#16358](jestjs/jest#16358)) - `[jest-haste-map]` Keep a duplicated manual mock resolving when the file it pointed at is deleted in watch mode ([#16360](jestjs/jest#16360)) - `[jest-haste-map]` Shut the worker farm down when a duplicate manual mock aborts the build under `throwOnModuleCollision` ([#16354](jestjs/jest#16354)) - `[jest-haste-map]` Attach the watchman client's `error` listener before the first command, so a watchman failure falls back to the node crawler instead of crashing on an unhandled `error` event, and always end the client ([#16355](jestjs/jest#16355)) - `[jest-haste-map]` Stop delivering watch events after `WatchmanWatcher` is closed, and route its warnings through the configured console ([#16355](jestjs/jest#16355)) - `[jest-haste-map]` Restore the nested `duplicates` index correctly in `ModuleMap.fromJSON`, so a haste collision reported inside a test worker raises `DuplicateHasteCandidatesError` instead of a `TypeError` ([#16353](jestjs/jest#16353)) - `[jest-haste-map]` Match watched files on a full extension, so `moduleFileExtensions: ['js']` no longer accepts `foo.mjs` ([#16352](jestjs/jest#16352)) - `[jest-haste-map]` Delimit the fields that make up the haste map cache key, so two different option sets cannot hash to the same cache file ([#16352](jestjs/jest#16352)) - `[jest-message-util]` Print the inner errors of an `AggregateError` thrown inside a test ([#16316](jestjs/jest#16316)) - `[jest-message-util]` Indent nested `cause` and `AggregateError` sections of a test failure by one level per depth, so the nesting is legible instead of rendering flat ([#16316](jestjs/jest#16316)) - `[jest-message-util]` Color stack traces line by line so blank lines stay blank ([#16316](jestjs/jest#16316)) - `[jest-message-util]` Detect Jest's own frames without assuming the checkout directory's name, and cover `@jest/*` packages, so stack traces and code frames point at user code ([#16326](jestjs/jest#16326)) - `[jest-mock]` `mockResolvedValue` / `mockRejectedValue` now see all overload return types, so a Promise-returning overload survives even when a later overload returns a non-Promise (e.g. `pg.Client['end']`) ([#16237](jestjs/jest#16237)) - `[@jest-environment/jsdom-abstract]` Make `@types/jsdom` a peer dependency ([#16166](jestjs/jest#16166)) - `[jest-mock]` Remove the leftover own accessor descriptor when restoring a `spyOn` of an inherited getter or setter, so the instance keeps reflecting the prototype ([#16226](jestjs/jest#16226)) - `[jest-resolve]` Include `extensionsToTreatAsEsm` in the `shouldLoadAsEsm` cache key, so projects with different extension lists don't read each other's answers ([#16369](jestjs/jest#16369)) - `[jest-resolve]` Make `getModuleIDAsync` build and cache `data:` URI module IDs the same way as `getModuleID` ([#16370](jestjs/jest#16370)) - `[jest-resolve]` Keep the `node:` prefix when resolving a core module asynchronously, so a builtin that only exists prefixed (`node:sea`, `node:sqlite`, `node:test`, `node:test/reporters`) resolves instead of failing as a missing bare package ([#16388](jestjs/jest#16388)) - `[jest-resolve]` Look up manual mocks for `node:` protocol specifiers under the unprefixed name they are stored as ([#16388](jestjs/jest#16388)) - `[jest-resolve]` Apply `moduleNameMapper` consistently to both spellings of core module specifiers (`fs` vs `node:fs`) ([#16390](jestjs/jest#16390)) - `[jest-resolve]` Keep virtual and ordinary mock module IDs isolated across test files ([#16296](jestjs/jest#16296)) - `[jest-resolve]` Guard missing `require.resolve.paths` ([#16052](jestjs/jest#16052)) - `[jest-resolve, jest-config, jest-runner]` Support a user resolver written as an ES module ([#16332](jestjs/jest#16332)) - `[jest-resolve, jest-runtime]` Throw the CJS parse error for ESM syntax in a `"type": "commonjs"` package or a `.cjs` file instead of loading it as ESM, matching Node ([#16368](jestjs/jest#16368)) - `[@jest/source-map]` Keep source map sources that name a scheme, such as `webpack:///`, instead of resolving them into a path that does not exist ([#16327](jestjs/jest#16327)) - `[@jest/source-map]` Look up `--testLocationInResults` positions at the right column, and keep a mapping to the first column instead of discarding it ([#16327](jestjs/jest#16327)) - `[@jest/source-map]` Warn when a source map cannot be parsed, instead of silently leaving its frames untranslated ([#16327](jestjs/jest#16327)) - `[jest-runner, @jest/source-map]` Keep a source-mapped stack for an error thrown after the test environment was torn down ([#16327](jestjs/jest#16327)) - `[jest-runtime, @jest/source-map]` Keep source maps past teardown and past the next test file's `install`, so a stack from a file no earlier stack mentioned still points at the original source ([#16330](jestjs/jest#16330)) - `[jest-runtime]` Report that no coverage was collected when `getAllV8CoverageInfoCopy` is called after `teardown`, instead of returning an empty result ([#16385](jestjs/jest#16385)) - `[jest-runtime]` Cache a CJS module's parsed exports before walking its re-exports, so two modules that re-export each other no longer overflow the stack when imported from ESM ([#16363](jestjs/jest#16363)) - `[jest-runtime]` Keep a re-exported ES module's parse failure from marking the re-exporting CommonJS file as ESM, so `module.exports = require('./dep.mjs')` loads instead of failing with `module is not defined` ([#16363](jestjs/jest#16363)) - `[jest-runtime]` Scope module mocks instantiated inside `jest.isolateModules`/`isolateModulesAsync` to that block, so a mock first imported there no longer outlives it - matching how CommonJS mocks already behave ([#16365](jestjs/jest#16365)) - `[jest-runtime]` Suspend module isolation while generating an automock, so loading the real module to read its shape no longer populates the isolated registry ([#16365](jestjs/jest#16365)) - `[jest-runtime]` Check a cached ES module's status before `require()` returns it, so a module whose evaluation threw rethrows that error and one left linked by a failed sibling is evaluated instead of returning uninitialized bindings ([#16364](jestjs/jest#16364)) - `[jest-runtime]` Report the original `ERR_REQUIRE_ASYNC_MODULE` when a `require()` of a top-level-await graph is retried, instead of a spurious "concurrent `import()`" error ([#16364](jestjs/jest#16364)) - `[jest-runtime]` Throw the evaluation error when another caller's `import()` of the same module failed while we awaited it, instead of resolving with the errored module ([#16364](jestjs/jest#16364)) - `[jest-runtime]` Mark the result of `require()`ing an ES module that has a default export with `__esModule: true` through a live-binding facade, and serve the same object from `require.cache`, matching Node ([#16367](jestjs/jest#16367)) - `[jest-runtime]` Provide a CommonJS module's exports under the `'module.exports'` named export when imported from ESM, matching Node 23+ ([#16367](jestjs/jest#16367)) - `[jest-runtime]` Give the test file itself a non-null `require.main` ([#16367](jestjs/jest#16367)) - `[jest-runtime]` Populate `module.children` with the modules a file loads, matching Node ([#16368](jestjs/jest#16368)) - `[jest-runtime]` Provide `import.meta.resolve` and `import.meta.jest` in `data:` URI modules, accept any-case mediatype parameters, and use Node's error codes for invalid `data:` URIs ([#16368](jestjs/jest#16368)) - `[jest-runtime]` Key ES modules by full URL, so query and fragment suffixes create the same module instances as Node and show up in `import.meta.url` ([#16375](jestjs/jest#16375)) - `[jest-runtime]` Share modules between overlapping graphs when a CommonJS module `require()`s an ES module mid-load, instead of evaluating shared dependencies twice ([#16375](jestjs/jest#16375)) - `[jest-runtime]` Throw `ERR_REQUIRE_CYCLE_MODULE` like Node when a CommonJS module `require()`s an ES module that is still being loaded, instead of evaluating the module a second time ([#16366](jestjs/jest#16366)) - `[jest-runtime]` Key builtin modules in the ESM registry by one canonical specifier ([#16341](jestjs/jest#16341)) - `[jest-runtime]` `import.meta.resolve()` for a builtin uses its `node:` specifier ([#16341](jestjs/jest#16341)) - `[jest-runtime]` Fall back to native ESM when a `.js` file contains ESM syntax but has no `"type":"module"` marker ([#16152](jestjs/jest#16152)) - `[jest-runtime]` Allow `require()` of ESM-marked files on Node < 24.9 via transform fallback ([#16244](jestjs/jest#16244)) - `[jest-runtime, @jest/transform]` Surface actionable `ERR_REQUIRE_ESM` error for files with untransformed ESM syntax instead of the generic "unexpected token" message ([#16244](jestjs/jest#16244)) - `[jest-runtime]` Support older test environments whose `moduleMocker` does not implement `clearMocksOnScope` ([#16169](jestjs/jest#16169)) - `[jest-runtime]` Apply `jest.unstable_mockModule` when the mocked file itself is `require()`d, not only when it is imported as a dependency ([#16389](jestjs/jest#16389)) - `[jest-runtime]` Apply `jest.unstable_mockModule` to statically imported `data:` URIs on Node 24.9+, matching dynamic `import()` ([#16389](jestjs/jest#16389)) - `[jest-runtime]` Run an async `jest.unstable_mockModule` factory once per module instead of twice, and fail the import instead of crashing the worker when the factory rejects ([#16389](jestjs/jest#16389)) - `[jest-runtime]` Hide a `require(esm)` module that failed to evaluate from `require.cache`, as Node does, instead of exposing a namespace with uninitialized bindings ([#16389](jestjs/jest#16389)) - `[jest-runtime]` Strip the byte-order mark when importing a JSON module, matching `require()` and Node ([#16389](jestjs/jest#16389)) - `[jest-runtime]` Throw `ERR_REQUIRE_ASYNC_MODULE` when `require(esm)` runs under an async-only custom resolver, instead of silently resolving with the default resolver ([#16389](jestjs/jest#16389)) - `[jest-runtime]` Parse imported JSON modules with the test realm's `JSON`, so their objects pass `instanceof Object` inside the test like `require()`d JSON does ([#16389](jestjs/jest#16389)) - `[jest-runtime]` Accept every `file:` URL string in the sandboxed `module.createRequire`, including one with a `localhost` authority, as Node does ([#16389](jestjs/jest#16389)) - `[jest-runtime]` Point at `{virtual: true}` when `jest.mock` or `jest.unstable_mockModule` is given a module that cannot be resolved ([#16389](jestjs/jest#16389)) - `[jest-reporters]` Fix coverage report table formatting in CI/GitHub Actions environments where `process.stdout.columns` is undefined by falling back to the `COLUMNS` env var or `80` columns in CI, preserving existing behaviour in other non-TTY environments ([#16227](jestjs/jest#16227)) - `[jest-runtime]` Support CJS-in-ESM exports via `"module.exports"` named exports ([#16277](jestjs/jest#16277)) - `[jest-snapshot]` Keep a skipped or failed test's hinted snapshots, instead of reporting them obsolete ([#16348](jestjs/jest#16348)) - `[jest-util]` Stop `globsToMatcher` reusing a cached matcher compiled with different picomatch options, and keep its `dot: true` default when `dot` is passed as `undefined` ([#16381](jestjs/jest#16381)) - `[pretty-format]` Move the `react-is` aliases into the `@jest` scope, so they cannot be shadowed by unrelated packages published under the alias names ([#16333](jestjs/jest#16333)) ##### Chore & Maintenance - `[docs]` Document the intentional divergences from Node's module system in the ECMAScript Modules page ([#16368](jestjs/jest#16368)) - `[docs]` Note deprecation of `react-test-renderer` in React Native tutorial and `pretty-format` README ([#16294](jestjs/jest#16294)) - `[docs]` Use `@testing-library/react-native` in the React Native tutorial instead of the deprecated `react-test-renderer` ([#16318](jestjs/jest#16318)) - `[babel-jest, @jest/transform]` Update `babel-plugin-istanbul` to v8 ([#16049](jestjs/jest#16049)) - `[jest-config, @jest/reporters, jest-runtime]` Update `glob` to v13 ([#16397](jestjs/jest#16397)) - `[jest-haste-map]` Refactor massive class into multiple files ([#16180](jestjs/jest#16180)) - `[jest-haste-map]` Drop `walker` dependency; replace hand-rolled directory recursion in the JS crawler and watcher startup with `fdir` ([#16187](jestjs/jest#16187)) - `[jest-haste-map]` Reuse cached metadata for files whose haste name is a known duplicate, instead of re-reading and re-parsing them on every startup ([#16351](jestjs/jest#16351)) - `[jest-haste-map]` Cache the watchman socket path and replace the `watchman --version` probe with `get-sockname`, so warm runs spawn no watchman processes ([#16386](jestjs/jest#16386)) - `[jest-resolve]` Store the per-directory package-type lookup in the cache it reads, so it actually memoizes ([#16369](jestjs/jest#16369)) - `[jest-resolve, jest-runtime]` Cut repeated work on the resolution hot path: hoist the platform-extension list to construction, memoize `isCoreModule` and the options cache-key serialization, skip mapper preparation when no `moduleNameMapper` is configured, run each mapper regex once, and stop re-parsing `NODE_OPTIONS` on every default-resolver call ([#16371](jestjs/jest#16371)) - `[jest-resolve]` Cut warm resolution cost to about a third: reuse one `unrs-resolver` factory per options shape instead of cloning per resolution, compose the factory cache key from per-array cached strings instead of serializing options, and stop constructing an `Error` for misses that `findNodeModule` swallows; add a `__benchmarks__` suite for the default resolver ([#16373](jestjs/jest#16373)) - `[jest-runner, @jest/source-map]` Replace `source-map-support` with an implementation in `@jest/source-map` ([#16327](jestjs/jest#16327)) - `[jest-snapshot]` Load babel, semver and synckit lazily, so requiring the package (which every test process does through `@jest/expect`) no longer loads \~200 modules that only writing inline snapshots needs ([#16387](jestjs/jest#16387)) - `[jest-runtime]` Reduce per-require overhead: skip module ID resolution when no mock can apply, answer core modules before probing for a manual mock, share one `require.cache` proxy across modules, and cache empty files ([#16376](jestjs/jest#16376)) - `[@jest/source-map]` Deprecate `getCallsite` in favour of `SourceMapSupport#getCallsite` ([#16327](jestjs/jest#16327)) - `[jest-runtime]` Avoid magical `null` value in ESM loader ([#16160](jestjs/jest#16160))
| datasource | package | from | to | | ---------- | ----------- | ------ | ------ | | npm | @jest/types | 30.4.1 | 30.5.1 | | npm | jest | 30.4.2 | 30.5.1 | ## [v30.5.1](https://github.com/jestjs/jest/blob/HEAD/CHANGELOG.md#3051) ##### Fixes - `[jest-config]` Don't warn about global-only options in the config that supplies the global config - the root config a project resolves to, or the first entry of `--projects` when no root config is passed ([#16411](jestjs/jest#16411)) - `[jest-config, jest-types]` Stop accepting `reporters`, `coverageReporters`, `workerIdleMemoryLimit`, `cwd` and `runnerOptions` in a project config - they were silently ignored, and now warn like the other global-only options ([#16411](jestjs/jest#16411)) - `[jest-config, jest-validate]` Warn about `maxWorkers` and `coverageThreshold` in a project config instead of dropping them without a word ([#16411](jestjs/jest#16411)) - `[jest-resolve]` Match `moduleNameMapper` patterns against the specifier as written again (reverting [#16390](jestjs/jest#16390)) ([#16417](jestjs/jest#16417)) - `[jest-runtime]` Resolve package `imports` specifiers like `#dep` under ESM again ([#16413](jestjs/jest#16413)) ##### Chore & Maintenance - `[jest-util]` Name the `testEnvironmentOptions.globalsCleanup` option and link the docs from the `JEST-01` deprecation warning, and document the option's modes ([#16404](jestjs/jest#16404)) ## [v30.5.0](https://github.com/jestjs/jest/blob/HEAD/CHANGELOG.md#3050) ##### Features - `[@jest/expect-utils, jest-mock]` Add `mockFn.whenCalledWith(...args)` for configuring return values per argument list, with first-class asymmetric-matcher support ([#16053](jestjs/jest#16053)) - `[@jest/expect-utils]` Export `AsymmetricMatcher` and `FunctionParameters` types (previously private to `expect`) ([#16053](jestjs/jest#16053)) - `[jest-circus, jest-core, jest-jasmine2, jest-test-result, jest-types]` `--collectTests` now expands `test.each`/`describe.each` cases and reports per-status counts (skipped/todo via the new `wouldRun` flag for selected tests) plus a summary line that match a real run, including under `--testNamePattern` and `.only`/`fdescribe` focus on both the circus and jasmine2 runners ([#16259](jestjs/jest#16259)) - `[jest-circus, jest-environment, jest-runtime, jest-types]` Add describe-level retries via `jest.retryTimes(..., {entireDescribe: true})` ([#16322](jestjs/jest#16322)) - `[jest-circus, jest-message-util, jest-reporters, jest-types]` Add `retryMessages` to `AssertionResult` and export `formatErrorStack`, so the retry log renders nested `cause` and `AggregateError` sections with code frames instead of serialized `[cause]:`/`[errors]:` markers ([#16316](jestjs/jest#16316)) - `[jest-circus, jest-types]` Add `unhandledErrorsDetailed` to `Circus.RunResult`, so an unhandled rejection reports its `cause` chain and `AggregateError` entries with code frames instead of a pre-serialized stack ([#16316](jestjs/jest#16316)) - `[jest-haste-map]` Replace `NodeWatcher` and `FSEventsWatcher` with `@parcel/watcher` for the non-watchman watch path ([#16188](jestjs/jest#16188)) - `[jest-resolve]` Bump `unrs-resolver` to 1.12.1, remove `jest-pnp-resolver` and unnecessary checks ([#15721](jestjs/jest#15721)) - `[jest-resolve]` Honor Node's `--preserve-symlinks` / `NODE_PRESERVE_SYMLINKS` in the default resolver by passing `symlinks: false` to `unrs-resolver` ([#16260](jestjs/jest#16260)) - `[jest-runtime]` Apply automocking and manual `__mocks__` files to synchronously evaluable ESM graphs on Node 24.9+ - static imports, dynamic `import()` and `require()` of an ESM file now generate an automock from the real module's namespace instead of failing with "Attempting to import a mock without a factory". Graphs that need async evaluation (top-level await) or an async-only resolver or transformer still throw ([#16391](jestjs/jest#16391)) - `[jest-runtime]` Route `process.getBuiltinModule` through the sandbox, so it returns the sandbox `process` and the hooked `node:module` instead of the host's ([#16391](jestjs/jest#16391)) - `[jest-runtime]` Throw an actionable error from `module.register()` and `module.registerHooks()` inside a test - the hooks attached to the loader running Jest itself, never saw the sandboxed requires they were meant for, and stayed registered for every later test file in the worker ([#16391](jestjs/jest#16391)) - `[jest-runtime]` Surface resolution and import-attribute errors in an ESM graph before executing any of its CJS dependencies on Node 24.9+, matching Node's run-nothing-on-a-broken-graph behavior; the legacy loader on older versions keeps its linking-time execution order ([#16391](jestjs/jest#16391)) - `[jest-runtime]` Throw `ERR_SOURCE_PHASE_NOT_DEFINED` with an actionable message for `import source` and `import.source()`, instead of failing at instantiation with V8's bare "Source phase import object is not defined" ([#16391](jestjs/jest#16391)) - `[jest-runtime]` Emit the JSON-without-import-attribute deprecation warning once per test file instead of once per worker, so it is no longer silently swallowed for every file after the first ([#16391](jestjs/jest#16391)) - `[jest-runtime]` Set `import.meta.main` to `true` in the test file and `false` in every module it loads, matching Node 24+ ([#16367](jestjs/jest#16367)) - `[jest-runtime]` Resolve the `module-sync` export condition, so a package that exposes its ESM entry point for `require()` loads the same file Node would ([#16336](jestjs/jest#16336)) - `[jest-snapshot]` Add external snapshot paths to custom reporter failure details ([#16374](jestjs/jest#16374)) ##### Fixes - `[jest-console, jest-reporters]` `CustomConsole` now buffers console output so `TestResult.console` is populated for reporters when `verbose` is enabled, while `GitHubActionsReporter` avoids replaying buffered output in verbose mode ([#16155](jestjs/jest#16155)) - `[expect, jest-message-util, jest-pattern, jest-regex-util, jest-util]` Revert `node:` protocol imports to restore webpack/browser-bundle compatibility ([#16167](jestjs/jest#16167)) - `[expect]` Widen `toMatchObject` and `objectContaining` parameter type from `Record<string, unknown>` to `object` so class instances are accepted ([#16196](jestjs/jest#16196)) - `[jest-circus]` Call a generator test body with the shared test context, so `this` matches what a regular test function receives ([#16347](jestjs/jest#16347)) - `[jest-circus]` Capture the error listeners of the parent process instead of the in-sandbox `process`, so listeners registered before the test file survive teardown and sandbox listeners no longer leak onto the parent ([#16347](jestjs/jest#16347)) - `[jest-circus]` Clear `currentlyRunningTest` after skipped and todo tests ([#16342](jestjs/jest#16342)) - `[jest-circus]` Prevent late `done()` callbacks from affecting later test or hook invocations ([#16343](jestjs/jest#16343)) - `[jest-circus, jest-jasmine2]` Honor `--expand` when formatting `node:assert` failures, instead of always collapsing the diff ([#16347](jestjs/jest#16347)) - `[jest-circus, jest-jasmine2, jest-message-util]` Serialize the inner errors of an `AggregateError` into `failureMessages`, `retryReasons` and `unhandledErrors`, so `--json` output and reporter annotations include them ([#16316](jestjs/jest#16316)) - `[jest-circus, jest-snapshot]` Keep snapshot state and counts correct when a test retries ([#16344](jestjs/jest#16344)) - `[@jest/create-cache-key-function]` Include the caller support flags in the generated key, so a transformer that emits ESM or CJS based on them no longer shares one cache entry between the two ([#16331](jestjs/jest#16331)) - `[@jest/create-cache-key-function]` Include the stringified project config in the generated key, so editing a transformer's own settings invalidates what it cached ([#16331](jestjs/jest#16331)) - `[@jest/transform]` Include the caller support flags in a transform's cache key, so a file transformed both as ESM and as CJS no longer serves one shape's output for the other ([#16331](jestjs/jest#16331)) - `[jest-config]` Add missing `findRelatedTests`, `outputFile`, and `replname` entries to `ValidConfig` so they no longer trigger spurious "Unknown option" warnings ([#16224](jestjs/jest#16224)) - `[jest-config]` Use `--config` for the global config when multiple `--projects` are specified ([#16273](jestjs/jest#16273)) - `[jest-core]` Serialize `bigint` values in `--json` and `--outputFile` output as their literal form (`4n`), instead of failing the run with `TypeError: Do not know how to serialize a BigInt` ([#16338](jestjs/jest#16338)) - `[jest-core]` Do not report a `CustomGC` async resource (used by N-API addons such as napi-rs for per-isolate GC bookkeeping) as an open handle, since it is `napi_unref`'d by the addon and can never keep the event loop alive ([#16379](jestjs/jest#16379)) - `[jest-each]` Keep a `$&`, `` $` ``, `$'` or `$$` inside a `%p` param value out of the replacement, so the title shows the value instead of the text around it ([#16338](jestjs/jest#16338)) - `[jest-each]` Interpolate a `bigint` into a `%j` title as its literal form (`"4n"`) at any depth, instead of throwing `TypeError: Do not know how to serialize a BigInt` while collecting the tests ([#16338](jestjs/jest#16338)) - `[jest-environment, jest-runtime]` Bind `sandboxInjectedGlobals` to the right values when `injectGlobals` is `false`, instead of shifting every one of them by a position ([#16377](jestjs/jest#16377)) - `[jest-environment-node, jest-util]` Only warn about a conflicting `globalsCleanup` mode when one was explicitly configured, and follow the mode that is actually in effect ([#16323](jestjs/jest#16323)) - `[jest-environment-node, jest-util]` Stop resolving lazy globals when setting up an environment, so Node 26's builtin module globals are no longer loaded (and no longer emit their deprecation warnings) for every test file ([#16324](jestjs/jest#16324)) - `[jest-haste-map]` Keep watch mode alive when an outside process briefly makes a file unreadable on Windows, instead of tearing the watcher down on `EPERM` ([#16295](jestjs/jest#16295)) - `[jest-haste-map]` Keep indexing when an outside process holds a file open on Windows, instead of failing the whole crawl on `EPERM` ([#16358](jestjs/jest#16358)) - `[jest-haste-map]` Keep a duplicated manual mock resolving when the file it pointed at is deleted in watch mode ([#16360](jestjs/jest#16360)) - `[jest-haste-map]` Shut the worker farm down when a duplicate manual mock aborts the build under `throwOnModuleCollision` ([#16354](jestjs/jest#16354)) - `[jest-haste-map]` Attach the watchman client's `error` listener before the first command, so a watchman failure falls back to the node crawler instead of crashing on an unhandled `error` event, and always end the client ([#16355](jestjs/jest#16355)) - `[jest-haste-map]` Stop delivering watch events after `WatchmanWatcher` is closed, and route its warnings through the configured console ([#16355](jestjs/jest#16355)) - `[jest-haste-map]` Restore the nested `duplicates` index correctly in `ModuleMap.fromJSON`, so a haste collision reported inside a test worker raises `DuplicateHasteCandidatesError` instead of a `TypeError` ([#16353](jestjs/jest#16353)) - `[jest-haste-map]` Match watched files on a full extension, so `moduleFileExtensions: ['js']` no longer accepts `foo.mjs` ([#16352](jestjs/jest#16352)) - `[jest-haste-map]` Delimit the fields that make up the haste map cache key, so two different option sets cannot hash to the same cache file ([#16352](jestjs/jest#16352)) - `[jest-message-util]` Print the inner errors of an `AggregateError` thrown inside a test ([#16316](jestjs/jest#16316)) - `[jest-message-util]` Indent nested `cause` and `AggregateError` sections of a test failure by one level per depth, so the nesting is legible instead of rendering flat ([#16316](jestjs/jest#16316)) - `[jest-message-util]` Color stack traces line by line so blank lines stay blank ([#16316](jestjs/jest#16316)) - `[jest-message-util]` Detect Jest's own frames without assuming the checkout directory's name, and cover `@jest/*` packages, so stack traces and code frames point at user code ([#16326](jestjs/jest#16326)) - `[jest-mock]` `mockResolvedValue` / `mockRejectedValue` now see all overload return types, so a Promise-returning overload survives even when a later overload returns a non-Promise (e.g. `pg.Client['end']`) ([#16237](jestjs/jest#16237)) - `[@jest-environment/jsdom-abstract]` Make `@types/jsdom` a peer dependency ([#16166](jestjs/jest#16166)) - `[jest-mock]` Remove the leftover own accessor descriptor when restoring a `spyOn` of an inherited getter or setter, so the instance keeps reflecting the prototype ([#16226](jestjs/jest#16226)) - `[jest-resolve]` Include `extensionsToTreatAsEsm` in the `shouldLoadAsEsm` cache key, so projects with different extension lists don't read each other's answers ([#16369](jestjs/jest#16369)) - `[jest-resolve]` Make `getModuleIDAsync` build and cache `data:` URI module IDs the same way as `getModuleID` ([#16370](jestjs/jest#16370)) - `[jest-resolve]` Keep the `node:` prefix when resolving a core module asynchronously, so a builtin that only exists prefixed (`node:sea`, `node:sqlite`, `node:test`, `node:test/reporters`) resolves instead of failing as a missing bare package ([#16388](jestjs/jest#16388)) - `[jest-resolve]` Look up manual mocks for `node:` protocol specifiers under the unprefixed name they are stored as ([#16388](jestjs/jest#16388)) - `[jest-resolve]` Apply `moduleNameMapper` consistently to both spellings of core module specifiers (`fs` vs `node:fs`) ([#16390](jestjs/jest#16390)) - `[jest-resolve]` Keep virtual and ordinary mock module IDs isolated across test files ([#16296](jestjs/jest#16296)) - `[jest-resolve]` Guard missing `require.resolve.paths` ([#16052](jestjs/jest#16052)) - `[jest-resolve, jest-config, jest-runner]` Support a user resolver written as an ES module ([#16332](jestjs/jest#16332)) - `[jest-resolve, jest-runtime]` Throw the CJS parse error for ESM syntax in a `"type": "commonjs"` package or a `.cjs` file instead of loading it as ESM, matching Node ([#16368](jestjs/jest#16368)) - `[@jest/source-map]` Keep source map sources that name a scheme, such as `webpack:///`, instead of resolving them into a path that does not exist ([#16327](jestjs/jest#16327)) - `[@jest/source-map]` Look up `--testLocationInResults` positions at the right column, and keep a mapping to the first column instead of discarding it ([#16327](jestjs/jest#16327)) - `[@jest/source-map]` Warn when a source map cannot be parsed, instead of silently leaving its frames untranslated ([#16327](jestjs/jest#16327)) - `[jest-runner, @jest/source-map]` Keep a source-mapped stack for an error thrown after the test environment was torn down ([#16327](jestjs/jest#16327)) - `[jest-runtime, @jest/source-map]` Keep source maps past teardown and past the next test file's `install`, so a stack from a file no earlier stack mentioned still points at the original source ([#16330](jestjs/jest#16330)) - `[jest-runtime]` Report that no coverage was collected when `getAllV8CoverageInfoCopy` is called after `teardown`, instead of returning an empty result ([#16385](jestjs/jest#16385)) - `[jest-runtime]` Cache a CJS module's parsed exports before walking its re-exports, so two modules that re-export each other no longer overflow the stack when imported from ESM ([#16363](jestjs/jest#16363)) - `[jest-runtime]` Keep a re-exported ES module's parse failure from marking the re-exporting CommonJS file as ESM, so `module.exports = require('./dep.mjs')` loads instead of failing with `module is not defined` ([#16363](jestjs/jest#16363)) - `[jest-runtime]` Scope module mocks instantiated inside `jest.isolateModules`/`isolateModulesAsync` to that block, so a mock first imported there no longer outlives it - matching how CommonJS mocks already behave ([#16365](jestjs/jest#16365)) - `[jest-runtime]` Suspend module isolation while generating an automock, so loading the real module to read its shape no longer populates the isolated registry ([#16365](jestjs/jest#16365)) - `[jest-runtime]` Check a cached ES module's status before `require()` returns it, so a module whose evaluation threw rethrows that error and one left linked by a failed sibling is evaluated instead of returning uninitialized bindings ([#16364](jestjs/jest#16364)) - `[jest-runtime]` Report the original `ERR_REQUIRE_ASYNC_MODULE` when a `require()` of a top-level-await graph is retried, instead of a spurious "concurrent `import()`" error ([#16364](jestjs/jest#16364)) - `[jest-runtime]` Throw the evaluation error when another caller's `import()` of the same module failed while we awaited it, instead of resolving with the errored module ([#16364](jestjs/jest#16364)) - `[jest-runtime]` Mark the result of `require()`ing an ES module that has a default export with `__esModule: true` through a live-binding facade, and serve the same object from `require.cache`, matching Node ([#16367](jestjs/jest#16367)) - `[jest-runtime]` Provide a CommonJS module's exports under the `'module.exports'` named export when imported from ESM, matching Node 23+ ([#16367](jestjs/jest#16367)) - `[jest-runtime]` Give the test file itself a non-null `require.main` ([#16367](jestjs/jest#16367)) - `[jest-runtime]` Populate `module.children` with the modules a file loads, matching Node ([#16368](jestjs/jest#16368)) - `[jest-runtime]` Provide `import.meta.resolve` and `import.meta.jest` in `data:` URI modules, accept any-case mediatype parameters, and use Node's error codes for invalid `data:` URIs ([#16368](jestjs/jest#16368)) - `[jest-runtime]` Key ES modules by full URL, so query and fragment suffixes create the same module instances as Node and show up in `import.meta.url` ([#16375](jestjs/jest#16375)) - `[jest-runtime]` Share modules between overlapping graphs when a CommonJS module `require()`s an ES module mid-load, instead of evaluating shared dependencies twice ([#16375](jestjs/jest#16375)) - `[jest-runtime]` Throw `ERR_REQUIRE_CYCLE_MODULE` like Node when a CommonJS module `require()`s an ES module that is still being loaded, instead of evaluating the module a second time ([#16366](jestjs/jest#16366)) - `[jest-runtime]` Key builtin modules in the ESM registry by one canonical specifier ([#16341](jestjs/jest#16341)) - `[jest-runtime]` `import.meta.resolve()` for a builtin uses its `node:` specifier ([#16341](jestjs/jest#16341)) - `[jest-runtime]` Fall back to native ESM when a `.js` file contains ESM syntax but has no `"type":"module"` marker ([#16152](jestjs/jest#16152)) - `[jest-runtime]` Allow `require()` of ESM-marked files on Node < 24.9 via transform fallback ([#16244](jestjs/jest#16244)) - `[jest-runtime, @jest/transform]` Surface actionable `ERR_REQUIRE_ESM` error for files with untransformed ESM syntax instead of the generic "unexpected token" message ([#16244](jestjs/jest#16244)) - `[jest-runtime]` Support older test environments whose `moduleMocker` does not implement `clearMocksOnScope` ([#16169](jestjs/jest#16169)) - `[jest-runtime]` Apply `jest.unstable_mockModule` when the mocked file itself is `require()`d, not only when it is imported as a dependency ([#16389](jestjs/jest#16389)) - `[jest-runtime]` Apply `jest.unstable_mockModule` to statically imported `data:` URIs on Node 24.9+, matching dynamic `import()` ([#16389](jestjs/jest#16389)) - `[jest-runtime]` Run an async `jest.unstable_mockModule` factory once per module instead of twice, and fail the import instead of crashing the worker when the factory rejects ([#16389](jestjs/jest#16389)) - `[jest-runtime]` Hide a `require(esm)` module that failed to evaluate from `require.cache`, as Node does, instead of exposing a namespace with uninitialized bindings ([#16389](jestjs/jest#16389)) - `[jest-runtime]` Strip the byte-order mark when importing a JSON module, matching `require()` and Node ([#16389](jestjs/jest#16389)) - `[jest-runtime]` Throw `ERR_REQUIRE_ASYNC_MODULE` when `require(esm)` runs under an async-only custom resolver, instead of silently resolving with the default resolver ([#16389](jestjs/jest#16389)) - `[jest-runtime]` Parse imported JSON modules with the test realm's `JSON`, so their objects pass `instanceof Object` inside the test like `require()`d JSON does ([#16389](jestjs/jest#16389)) - `[jest-runtime]` Accept every `file:` URL string in the sandboxed `module.createRequire`, including one with a `localhost` authority, as Node does ([#16389](jestjs/jest#16389)) - `[jest-runtime]` Point at `{virtual: true}` when `jest.mock` or `jest.unstable_mockModule` is given a module that cannot be resolved ([#16389](jestjs/jest#16389)) - `[jest-reporters]` Fix coverage report table formatting in CI/GitHub Actions environments where `process.stdout.columns` is undefined by falling back to the `COLUMNS` env var or `80` columns in CI, preserving existing behaviour in other non-TTY environments ([#16227](jestjs/jest#16227)) - `[jest-runtime]` Support CJS-in-ESM exports via `"module.exports"` named exports ([#16277](jestjs/jest#16277)) - `[jest-snapshot]` Keep a skipped or failed test's hinted snapshots, instead of reporting them obsolete ([#16348](jestjs/jest#16348)) - `[jest-util]` Stop `globsToMatcher` reusing a cached matcher compiled with different picomatch options, and keep its `dot: true` default when `dot` is passed as `undefined` ([#16381](jestjs/jest#16381)) - `[pretty-format]` Move the `react-is` aliases into the `@jest` scope, so they cannot be shadowed by unrelated packages published under the alias names ([#16333](jestjs/jest#16333)) ##### Chore & Maintenance - `[docs]` Document the intentional divergences from Node's module system in the ECMAScript Modules page ([#16368](jestjs/jest#16368)) - `[docs]` Note deprecation of `react-test-renderer` in React Native tutorial and `pretty-format` README ([#16294](jestjs/jest#16294)) - `[docs]` Use `@testing-library/react-native` in the React Native tutorial instead of the deprecated `react-test-renderer` ([#16318](jestjs/jest#16318)) - `[babel-jest, @jest/transform]` Update `babel-plugin-istanbul` to v8 ([#16049](jestjs/jest#16049)) - `[jest-config, @jest/reporters, jest-runtime]` Update `glob` to v13 ([#16397](jestjs/jest#16397)) - `[jest-haste-map]` Refactor massive class into multiple files ([#16180](jestjs/jest#16180)) - `[jest-haste-map]` Drop `walker` dependency; replace hand-rolled directory recursion in the JS crawler and watcher startup with `fdir` ([#16187](jestjs/jest#16187)) - `[jest-haste-map]` Reuse cached metadata for files whose haste name is a known duplicate, instead of re-reading and re-parsing them on every startup ([#16351](jestjs/jest#16351)) - `[jest-haste-map]` Cache the watchman socket path and replace the `watchman --version` probe with `get-sockname`, so warm runs spawn no watchman processes ([#16386](jestjs/jest#16386)) - `[jest-resolve]` Store the per-directory package-type lookup in the cache it reads, so it actually memoizes ([#16369](jestjs/jest#16369)) - `[jest-resolve, jest-runtime]` Cut repeated work on the resolution hot path: hoist the platform-extension list to construction, memoize `isCoreModule` and the options cache-key serialization, skip mapper preparation when no `moduleNameMapper` is configured, run each mapper regex once, and stop re-parsing `NODE_OPTIONS` on every default-resolver call ([#16371](jestjs/jest#16371)) - `[jest-resolve]` Cut warm resolution cost to about a third: reuse one `unrs-resolver` factory per options shape instead of cloning per resolution, compose the factory cache key from per-array cached strings instead of serializing options, and stop constructing an `Error` for misses that `findNodeModule` swallows; add a `__benchmarks__` suite for the default resolver ([#16373](jestjs/jest#16373)) - `[jest-runner, @jest/source-map]` Replace `source-map-support` with an implementation in `@jest/source-map` ([#16327](jestjs/jest#16327)) - `[jest-snapshot]` Load babel, semver and synckit lazily, so requiring the package (which every test process does through `@jest/expect`) no longer loads \~200 modules that only writing inline snapshots needs ([#16387](jestjs/jest#16387)) - `[jest-runtime]` Reduce per-require overhead: skip module ID resolution when no mock can apply, answer core modules before probing for a manual mock, share one `require.cache` proxy across modules, and cache empty files ([#16376](jestjs/jest#16376)) - `[@jest/source-map]` Deprecate `getCallsite` in favour of `SourceMapSupport#getCallsite` ([#16327](jestjs/jest#16327)) - `[jest-runtime]` Avoid magical `null` value in ESM loader ([#16160](jestjs/jest#16160))
|
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Summary
A review pass of
jest-runtimeagainst Node v26.7.0, follow-up to #16389. The PR grew through several review rounds; this describes the result as a whole.Automocking and manual
__mocks__files for ESMAny factory-less ESM mock decision used to crash with
Attempting to import a mock without a factory-automock: truemade every ESM import fail. On Node 24.9+ the ESM loader now mirrors the CJS mock machinery: a root or sibling__mocks__file loads as the mock (in its own format, resolved with import conditions), otherwise the real module loads in scratch registries and an automock is generated from its namespace. This covers static imports, dynamicimport(),require(esm)anddata:URIs, with the usual escape hatches intact:jest.requireActual,unmockedModulePathPatterns, andjest.unmock/jest.deepUnmock- whose CJS decisions, includingdeepUnmock's transitive scope, block a generated ESM mock. A registeredunstable_mockModulefactory still wins, since unmocking those isunstable_unmockModule's job.The details that took iteration to get right:
require()machinery routes ESM targets to the ESM loader - including unmarked ESM,.jsfiles whose transformed source has ESM syntax in a CommonJS package - so an.mjsmanual mock is never compiled as CommonJS and a factory-lessjest.mock('./esm.mjs')automocks instead of returning the real module.require()andimportshare one mock instance whenever both condition sets resolve to the same file; a conditional package whoserequire/module-syncandimportconditions diverge gets a mock of the file each entry point actually resolves - including its sibling__mocks__file.a.mjs <-> b.mjscycle links instead of failing on an empty placeholder.with { type: 'json' }.Node parity in the sandbox
process.getBuiltinModulewas the host function by reference: it returned the hostprocess(Node guaranteesprocess.getBuiltinModule('process') === process) and the hostnode:module, whosecreateRequireescapes Jest's registry, mocks and transforms. It now dispatches through therequireModuleoverride seam.module.register()andmodule.registerHooks()attached hooks to the loader running Jest itself - they observed Jest's internal requires, never the sandboxed ones, and persisted across test files in the worker. Both now throw an actionable error, alongside the existingsyncBuiltinESMExportsno-op.Graph errors surface before anything executes
Building a CJS dep's synthetic executes its body (the export-name merge needs the runtime exports object), and the walker built it the moment the specifier resolved - so
import './side-effect.cjs'; import './missing.js';ran the side effect before erroring, unlike Node's resolve-everything-first loader. CJS builds, automock generation and registered sync mock factories now all defer until the resolution worklist drains; unmarked-ESM files are classified without execution by probinghasEsmSyntaxon the transformed source, and a file both parsers reject still surfaces the canonical compile error. Applies to the sync graph walker (Node 24.9+); the legacy loader keeps its linking-time order, as documented.Resolvers with distinct sync and async hooks
Resolver#hasDistinctAsyncResolver()(new in jest-resolve) reports when a configured resolver exports both asyncand anasynchook. Such a resolver never enters a sync-preferred walk: even its successful sync resolutions may disagree with the async hook thatresolveModuleAsyncselects for imports.require()keeps the sync hook, since it cannot await; mock generation on the async path resolves through the async API before generating; and a mock generated forrequire()is not reused by a laterimport.Source phase imports
import source/import.source()(shipped unflagged in Node for WebAssembly) failed at instantiation with V8's bareSource phase import object is not definedpointing at Jest internals. Node satisfies the phase via the internalModuleWrap#setModuleSourceObject;node:vmexposes no equivalent, so the phase cannot be implemented on the vm-based loader. Source-phase requests now throwERR_SOURCE_PHASE_NOT_DEFINEDwith the gap explained - in the sync walker, the legacy loader, and the dynamic-import callbacks (ESM and CJS alike, which receive the phase as a fourth argument).require.cachestays path-addressedObject.keys(require.cache)leaked raw mock-ID strings,@jest/globalssynthetics and core specifiers. Mock modules no longer enter the ESM registry (they are served from the module-mock registry), and the proxy answers only for absolute-path keys - Node lists absolute file paths only.Cleanup
import.meta.resolve's divergence from Node (the full jest-resolve pipeline answers, resolution-only in Node) is pinned in a comment.data:URI decoding and import-attribute validation moved out ofEsmLoaderintodataUri.tsandimportAttributes.ts. The attribute validator's warned-pairs set moved from module scope to the instance, so the JSON-without-attribute deprecation warning fires once per test file instead of once per worker.Test plan
~65 new regression tests across
runtime_esm_sync_graph.test.ts,runtime_environment.test.js,cjsRequire.test.ts,resolve.test.tsand the extractedimportAttributes.test.ts, backed by new fixtures (conditional packages, dual- and disagreeing-hook resolvers, root/sibling mocks, cycles, data: URIs, source-phase imports). Every fix was reproduced against the built CLI before the change and re-run after, with plainnodeoutput as the baseline where Node has the behavior natively.yarn jest packages/jest-runtime,yarn jest-runtime-vm-modules,yarn typecheck:testsandyarn lintare green on Node v26.7.0.