Thanks to visit codestin.com
Credit goes to github.com

Skip to content

feat: support require(esm)#16074

Merged
SimenB merged 17 commits into
jestjs:mainfrom
SimenB:require-esm
May 1, 2026
Merged

feat: support require(esm)#16074
SimenB merged 17 commits into
jestjs:mainfrom
SimenB:require-esm

Conversation

@SimenB
Copy link
Copy Markdown
Member

@SimenB SimenB commented May 1, 2026

Summary

Building on #16063 we can now finally support require(esm) 🎉

Test plan

Tests added

Copilot AI review requested due to automatic review settings May 1, 2026 09:18
@netlify
Copy link
Copy Markdown

netlify Bot commented May 1, 2026

Deploy Preview for jestjs ready!

Name Link
🔨 Latest commit dc31ec6
🔍 Latest deploy log https://app.netlify.com/projects/jestjs/deploys/69f4add3cfb21d000866ce62
😎 Deploy Preview https://deploy-preview-16074--jestjs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@SimenB SimenB linked an issue May 1, 2026 that may be closed by this pull request
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds Jest runtime support for Node’s require(esm) behavior (Node v24.9+), including surfacing Node-compatible error codes and exposing loaded ESM modules via require.cache.

Changes:

  • Implement synchronous require() of ESM modules (Node v24.9+), throwing ERR_REQUIRE_ASYNC_MODULE for async edges (e.g., TLA, async mock factories).
  • Extend require.cache to include ESM entries (module-shaped wrappers exposing exports as the namespace) with stable identity across reads.
  • Add unit + e2e coverage and document the new behavior (including Node version gating).

Reviewed changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
packages/jest-runtime/src/index.ts Core implementation of require(esm) sync path, Node-like error codes, and require.cache ESM exposure.
packages/jest-runtime/src/tests/test_esm_sync_graph_root/read-require-cache.cjs Test helper to read require.cache from inside a CJS module context.
packages/jest-runtime/src/tests/test_esm_sync_graph_root/import-data-uri-tla.mjs Fixture ensuring TLA inside data: deps surfaces ERR_REQUIRE_ASYNC_MODULE.
packages/jest-runtime/src/tests/runtime_esm_sync_graph.test.ts Unit tests covering require(esm) behavior, error surfacing, cache identity, and mocking semantics.
e2e/native-esm/tests/native-esm.test.js Removes prior expectation that require(esm) always throws ERR_REQUIRE_ESM.
e2e/native-esm-require-module/package.json New e2e project config for exercising require(esm) in Node environment.
e2e/native-esm-require-module/esm.mjs E2E ESM fixture for namespace return + default export behavior.
e2e/native-esm-require-module/esm-with-tla.mjs E2E ESM fixture for TLA → ERR_REQUIRE_ASYNC_MODULE.
e2e/native-esm-require-module/tests/require-esm.test.js E2E tests for successful require(esm) behavior and require.cache exposure.
e2e/native-esm-require-module/tests/require-esm-throws-on-old-node.test.js E2E test asserting old-Node gating throws ERR_REQUIRE_ESM with version hint.
e2e/tests/nativeEsmRequireModule.test.ts Harness running the new e2e project on version-gated Node ranges.
e2e/tests/snapshots/nativeEsm.test.ts.snap Snapshot update due to removed native-esm test.
docs/ECMAScriptModules.md Documentation for require() of ESM (Node v24.9+), errors, and mocking semantics.
CHANGELOG.md Changelog entry announcing require() support for ESM on Node v24.9+.

Comment thread packages/jest-runtime/src/index.ts Outdated
Comment thread packages/jest-runtime/src/index.ts
Comment thread packages/jest-runtime/src/index.ts
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 1, 2026

Open in StackBlitz

babel-jest

npm i https://pkg.pr.new/babel-jest@16074

babel-plugin-jest-hoist

npm i https://pkg.pr.new/babel-plugin-jest-hoist@16074

babel-preset-jest

npm i https://pkg.pr.new/babel-preset-jest@16074

create-jest

npm i https://pkg.pr.new/create-jest@16074

@jest/diff-sequences

npm i https://pkg.pr.new/@jest/diff-sequences@16074

expect

npm i https://pkg.pr.new/expect@16074

@jest/expect-utils

npm i https://pkg.pr.new/@jest/expect-utils@16074

jest

npm i https://pkg.pr.new/jest@16074

jest-changed-files

npm i https://pkg.pr.new/jest-changed-files@16074

jest-circus

npm i https://pkg.pr.new/jest-circus@16074

jest-cli

npm i https://pkg.pr.new/jest-cli@16074

jest-config

npm i https://pkg.pr.new/jest-config@16074

@jest/console

npm i https://pkg.pr.new/@jest/console@16074

@jest/core

npm i https://pkg.pr.new/@jest/core@16074

@jest/create-cache-key-function

npm i https://pkg.pr.new/@jest/create-cache-key-function@16074

jest-diff

npm i https://pkg.pr.new/jest-diff@16074

jest-docblock

npm i https://pkg.pr.new/jest-docblock@16074

jest-each

npm i https://pkg.pr.new/jest-each@16074

@jest/environment

npm i https://pkg.pr.new/@jest/environment@16074

jest-environment-jsdom

npm i https://pkg.pr.new/jest-environment-jsdom@16074

@jest/environment-jsdom-abstract

npm i https://pkg.pr.new/@jest/environment-jsdom-abstract@16074

jest-environment-node

npm i https://pkg.pr.new/jest-environment-node@16074

@jest/expect

npm i https://pkg.pr.new/@jest/expect@16074

@jest/fake-timers

npm i https://pkg.pr.new/@jest/fake-timers@16074

@jest/get-type

npm i https://pkg.pr.new/@jest/get-type@16074

@jest/globals

npm i https://pkg.pr.new/@jest/globals@16074

jest-haste-map

npm i https://pkg.pr.new/jest-haste-map@16074

jest-jasmine2

npm i https://pkg.pr.new/jest-jasmine2@16074

jest-leak-detector

npm i https://pkg.pr.new/jest-leak-detector@16074

jest-matcher-utils

npm i https://pkg.pr.new/jest-matcher-utils@16074

jest-message-util

npm i https://pkg.pr.new/jest-message-util@16074

jest-mock

npm i https://pkg.pr.new/jest-mock@16074

@jest/pattern

npm i https://pkg.pr.new/@jest/pattern@16074

jest-phabricator

npm i https://pkg.pr.new/jest-phabricator@16074

jest-regex-util

npm i https://pkg.pr.new/jest-regex-util@16074

@jest/reporters

npm i https://pkg.pr.new/@jest/reporters@16074

jest-resolve

npm i https://pkg.pr.new/jest-resolve@16074

jest-resolve-dependencies

npm i https://pkg.pr.new/jest-resolve-dependencies@16074

jest-runner

npm i https://pkg.pr.new/jest-runner@16074

jest-runtime

npm i https://pkg.pr.new/jest-runtime@16074

@jest/schemas

npm i https://pkg.pr.new/@jest/schemas@16074

jest-snapshot

npm i https://pkg.pr.new/jest-snapshot@16074

@jest/snapshot-utils

npm i https://pkg.pr.new/@jest/snapshot-utils@16074

@jest/source-map

npm i https://pkg.pr.new/@jest/source-map@16074

@jest/test-result

npm i https://pkg.pr.new/@jest/test-result@16074

@jest/test-sequencer

npm i https://pkg.pr.new/@jest/test-sequencer@16074

@jest/transform

npm i https://pkg.pr.new/@jest/transform@16074

@jest/types

npm i https://pkg.pr.new/@jest/types@16074

jest-util

npm i https://pkg.pr.new/jest-util@16074

jest-validate

npm i https://pkg.pr.new/jest-validate@16074

jest-watcher

npm i https://pkg.pr.new/jest-watcher@16074

jest-worker

npm i https://pkg.pr.new/jest-worker@16074

pretty-format

npm i https://pkg.pr.new/pretty-format@16074

commit: dc31ec6

@jmuransky
Copy link
Copy Markdown
Contributor

Nice! I will have a look at this now. Thank you

Comment thread docs/ECMAScriptModules.md Outdated
Copy link
Copy Markdown
Contributor

@jmuransky jmuransky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything else looks fine. Though the support is still not enough for me. Funnily the error I am getting is probably from nodejs:

Cannot require() ES Module FILE synchronously: it is currently being loaded by a concurrent import(). Await that import before calling require(), or import this module instead of requiring it.

I'll try to do minimal repro I can publish and see if there's anything to do about it

Comment thread packages/jest-runtime/src/index.ts Outdated
@SimenB
Copy link
Copy Markdown
Member Author

SimenB commented May 1, 2026

I'll try to do minimal repro I can publish and see if there's anything to do about it

Awesome, thanks! I'll happily take a look 🙂

Comment thread packages/jest-runtime/src/index.ts
Comment thread docs/ECMAScriptModules.md Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 29 out of 29 changed files in this pull request and generated 4 comments.

Comment thread packages/jest-runtime/src/index.ts Outdated
Comment thread packages/jest-runtime/src/index.ts
Comment thread e2e/__tests__/nativeEsmSyncLinker.test.ts Outdated
Comment thread docs/ECMAScriptModules.md
@SimenB SimenB merged commit ea62c13 into jestjs:main May 1, 2026
140 of 141 checks passed
@SimenB SimenB deleted the require-esm branch May 1, 2026 14:54
@@ -1713,12 +1821,23 @@ export default class Runtime {
}

if (this.unstable_shouldLoadAsEsm(modulePath)) {
Copy link
Copy Markdown
Contributor

@jmuransky jmuransky May 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just thinking about this.
Do we maybe want to handle case, where this function identifies code as cjs (using .js and package.json does not have type:"module"), but is actually esm? I mean in a manner of try/catch-ing loading the cjs module. I haven't experienced this issue in my repo, but I think I saw packages like that before (dual esm/cjs published code).
Than again I may misremember some details, so think about if this actually makes sense

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's

// The file may contain ESM syntax with no ESM marker (.mjs /
// "type":"module") - try loading as native ESM. If the ESM parser also
// rejects it, the original CJS error was the genuine one; surface it
// instead of the (less useful) ESM diagnostic.
const cjsSyntaxError = error as Error;
return this.loadEsmModule(modulePath).catch(esmError => {
throw isError(esmError) && esmError.name === 'SyntaxError'
? cjsSyntaxError
: esmError;
});
, no? Or am I misunderstanding?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's probably why I thought about this.

Well I tried to write fixture to test this case and it failed. I'll have a better look at this and see if I did it wrong or if I found a case where it does not apply

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah no, you meant the other way.

#16078 🙂

@SimenB
Copy link
Copy Markdown
Member Author

SimenB commented May 7, 2026

renovate Bot added a commit to andrei-picus-tink/auto-renovate that referenced this pull request May 8, 2026
| datasource | package | from   | to     |
| ---------- | ------- | ------ | ------ |
| npm        | jest    | 30.3.0 | 30.4.0 |


## [v30.4.0](https://github.com/jestjs/jest/blob/HEAD/CHANGELOG.md#3040)

##### Features

- `[babel-jest]` Support collecting coverage from `.mts`, `.cts` (and other) files ([#15994](jestjs/jest#15994))
- `[jest-circus, jest-cli, jest-config, jest-core, jest-jasmine2, jest-types]` Add `--collect-tests` flag to discover and list tests without executing them ([#16006](jestjs/jest#16006))
- `[jest-config, jest-runner, jest-worker]` Add `workerGracefulExitTimeout` config option to control how long workers are given to exit before being force-killed ([#15984](jestjs/jest#15984))
- `[jest-config]` Add support for `jest.config.mts` as a valid configuration file ([#16005](jestjs/jest#16005))
- `[jest-config, jest-core, jest-reporters, jest-runner]` `verbose` and `silent` can now be set per-project; the project-level value overrides the global value for that project's tests ([#16133](jestjs/jest#16133))
- `[@jest/fake-timers]` Accept `Temporal.Duration` in `jest.advanceTimersByTime()` and `jest.advanceTimersByTimeAsync()` ([#16128](jestjs/jest#16128))
- `[@jest/fake-timers]` Accept `Temporal.Instant` and `Temporal.ZonedDateTime` in `jest.setSystemTime()` and `useFakeTimers({now})` ([#16128](jestjs/jest#16128))
- `[@jest/fake-timers]` Support faking `Temporal.Now.*` ([#16131](jestjs/jest#16131))
- `[jest-mock]` Add `clearMocksOnScope(scope)` on `ModuleMocker` for clearing every mock function exposed on a scope object ([#16088](jestjs/jest#16088))
- `[jest-resolve]` Add `canResolveSync()` on `Resolver` so callers can detect when a user-configured resolver only exports an `async` hook ([#16064](jestjs/jest#16064))
- `[jest-runtime]` Use synchronous `evaluate()` for ES modules without top-level `await` on Node versions that support it (v24.9+), and prefer the synchronous transform path when a sync transformer is configured ([#16062](jestjs/jest#16062))
- `[jest-runtime]` Support `require()` of ES modules on Node v24.9+ ([#16074](jestjs/jest#16074))
- `[jest-runtime]` Validate TC39 import attributes (`with { type: 'json' }`) on ESM imports ([#16127](jestjs/jest#16127))
- `[@jest/transform]` Add `canTransformSync(filename)` on `ScriptTransformer` so callers can pick the sync vs async transform path ([#16062](jestjs/jest#16062))
- `[jest-util]` Add `isError` helper ([#16076](jestjs/jest#16076))
- `[pretty-format]` Support React 19 ([#16123](jestjs/jest#16123))

##### Fixes

- `[expect-utils]` Fix `toStrictEqual` failing on `structuredClone` results due to cross-realm constructor mismatch ([#15959](jestjs/jest#15959))
- `[@jest/expect-utils]` Prevent `toMatchObject`/subset matching from throwing when encountering exotic iterables ([#15952](jestjs/jest#15952))
- `[fake-timers]` Convert `Date` to milliseconds before passing to `@sinonjs/fake-timers` ([#16029](jestjs/jest#16029))
- `[jest]` Export `GlobalConfig` and `ProjectConfig` TypeScript types ([#16132](jestjs/jest#16132))
- `[jest-circus]` Prevent crash when `asyncError` is undefined for non-Error throws ([#16003](jestjs/jest#16003))
- `[jest-circus, jest-jasmine2]` Include `Error.cause` in JSON `failureMessages` output ([#15967](jestjs/jest#15967))
- `[jest-config]` Fix preset path resolution on Windows when the preset uses subpath `exports` ([#15961](jestjs/jest#15961))
- `[jest-config]` Allow `collectCoverage` and `coverageProvider` in project config without a validation warning ([#16132](jestjs/jest#16132))
- `[jest-config]` Project config validator now emits "is not supported in an individual project configuration" instead of "probably a typing mistake" for known global-only options ([#16132](jestjs/jest#16132))
- `[jest-environment-node]` Fix `--localstorage-file` warning on Node 25+ ([#16086](jestjs/jest#16086))
- `[jest-reporters]` Apply global coverage threshold to unmatched pattern files in addition to glob/path thresholds ([#16137](jestjs/jest#16137))
- `[jest-reporters, jest-runner, jest-runtime, jest-transform]` Fix coverage report not showing correct code coverage when using `projects` config option ([#16140](jestjs/jest#16140))
- `[jest-runtime]` Resolve `expect` and `@jest/expect` from the internal module registry so test-file imports share the same `JestAssertionError` as the global `expect` ([#16130](jestjs/jest#16130))
- `[jest-runtime]` Improve CJS-from-ESM interop: `__esModule`/Babel default unwrap, broader named-export coverage, and shared CJS singleton across importers ([#16050](jestjs/jest#16050))
- `[jest-runtime]` Load `.js` files with ESM syntax but no `"type":"module"` marker as native ESM ([#16050](jestjs/jest#16050))
- `[jest-runtime]` Extend the `.js`-with-ESM-syntax fallback to `require()` on Node v24.9+ - falls back to `require(esm)` when the CJS parser rejects ESM syntax ([#16078](jestjs/jest#16078))
- `[jest-runtime]` Fix deadlocks and double-evaluation in concurrent ESM and wasm imports ([#16050](jestjs/jest#16050))
- `[jest-runtime]` Fix error when `require()` is called after the Jest environment has been torn down ([#15951](jestjs/jest#15951))
- `[jest-runtime]` Fix missing error when `import()` is called after the Jest environment has been torn down ([#16080](jestjs/jest#16080))
- `[jest-runtime]` Fix virtual `unstable_mockModule` registrations not respected in ESM ([#16081](jestjs/jest#16081))
- `[jest-runtime]` Apply `moduleNameMapper` when resolving modules with `require.resolve()` and the `paths` option ([#16135](jestjs/jest#16135))

##### Chore & Maintenance

- `[@jest/fake-timers]` Upgrade `@sinonjs/fake-timers` ([#16139](jestjs/jest#16139))
- `[jest-runtime]` Use synchronous `linkRequests` / `instantiate` for ESM linking on Node v24.9+ ([#16063](jestjs/jest#16063))
renovate Bot added a commit to andrei-picus-tink/auto-renovate that referenced this pull request May 10, 2026
| datasource | package | from   | to     |
| ---------- | ------- | ------ | ------ |
| npm        | jest    | 30.3.0 | 30.4.2 |


## [v30.4.2](https://github.com/jestjs/jest/blob/HEAD/CHANGELOG.md#3042)

##### Fixes

- `[jest-runtime]` Fix named imports from CJS modules whose `module.exports` is a function with own-property exports ([#16150](jestjs/jest#16150))


## [v30.4.1](https://github.com/jestjs/jest/blob/HEAD/CHANGELOG.md#3041)

##### Features

- `[jest-config, jest-core, jest-runner, jest-schemas, jest-types]` Allow custom runner configuration options via tuple format `['runner-path', {options}]` ([#16141](jestjs/jest#16141))

##### Fixes

- `[jest-runtime]` Align CJS-from-ESM default export with Node: `module.exports` is always the ESM default, `__esModule` unwrapping is no longer applied ([#16143](jestjs/jest#16143))


## [v30.4.0](https://github.com/jestjs/jest/blob/HEAD/CHANGELOG.md#3040)

##### Features

- `[babel-jest]` Support collecting coverage from `.mts`, `.cts` (and other) files ([#15994](jestjs/jest#15994))
- `[jest-circus, jest-cli, jest-config, jest-core, jest-jasmine2, jest-types]` Add `--collect-tests` flag to discover and list tests without executing them ([#16006](jestjs/jest#16006))
- `[jest-config, jest-runner, jest-worker]` Add `workerGracefulExitTimeout` config option to control how long workers are given to exit before being force-killed ([#15984](jestjs/jest#15984))
- `[jest-config]` Add support for `jest.config.mts` as a valid configuration file ([#16005](jestjs/jest#16005))
- `[jest-config, jest-core, jest-reporters, jest-runner]` `verbose` and `silent` can now be set per-project; the project-level value overrides the global value for that project's tests ([#16133](jestjs/jest#16133))
- `[@jest/fake-timers]` Accept `Temporal.Duration` in `jest.advanceTimersByTime()` and `jest.advanceTimersByTimeAsync()` ([#16128](jestjs/jest#16128))
- `[@jest/fake-timers]` Accept `Temporal.Instant` and `Temporal.ZonedDateTime` in `jest.setSystemTime()` and `useFakeTimers({now})` ([#16128](jestjs/jest#16128))
- `[@jest/fake-timers]` Support faking `Temporal.Now.*` ([#16131](jestjs/jest#16131))
- `[jest-mock]` Add `clearMocksOnScope(scope)` on `ModuleMocker` for clearing every mock function exposed on a scope object ([#16088](jestjs/jest#16088))
- `[jest-resolve]` Add `canResolveSync()` on `Resolver` so callers can detect when a user-configured resolver only exports an `async` hook ([#16064](jestjs/jest#16064))
- `[jest-runtime]` Use synchronous `evaluate()` for ES modules without top-level `await` on Node versions that support it (v24.9+), and prefer the synchronous transform path when a sync transformer is configured ([#16062](jestjs/jest#16062))
- `[jest-runtime]` Support `require()` of ES modules on Node v24.9+ ([#16074](jestjs/jest#16074))
- `[jest-runtime]` Validate TC39 import attributes (`with { type: 'json' }`) on ESM imports ([#16127](jestjs/jest#16127))
- `[@jest/transform]` Add `canTransformSync(filename)` on `ScriptTransformer` so callers can pick the sync vs async transform path ([#16062](jestjs/jest#16062))
- `[jest-util]` Add `isError` helper ([#16076](jestjs/jest#16076))
- `[pretty-format]` Support React 19 ([#16123](jestjs/jest#16123))

##### Fixes

- `[expect-utils]` Fix `toStrictEqual` failing on `structuredClone` results due to cross-realm constructor mismatch ([#15959](jestjs/jest#15959))
- `[@jest/expect-utils]` Prevent `toMatchObject`/subset matching from throwing when encountering exotic iterables ([#15952](jestjs/jest#15952))
- `[fake-timers]` Convert `Date` to milliseconds before passing to `@sinonjs/fake-timers` ([#16029](jestjs/jest#16029))
- `[jest]` Export `GlobalConfig` and `ProjectConfig` TypeScript types ([#16132](jestjs/jest#16132))
- `[jest-circus]` Prevent crash when `asyncError` is undefined for non-Error throws ([#16003](jestjs/jest#16003))
- `[jest-circus, jest-jasmine2]` Include `Error.cause` in JSON `failureMessages` output ([#15967](jestjs/jest#15967))
- `[jest-config]` Fix preset path resolution on Windows when the preset uses subpath `exports` ([#15961](jestjs/jest#15961))
- `[jest-config]` Allow `collectCoverage` and `coverageProvider` in project config without a validation warning ([#16132](jestjs/jest#16132))
- `[jest-config]` Project config validator now emits "is not supported in an individual project configuration" instead of "probably a typing mistake" for known global-only options ([#16132](jestjs/jest#16132))
- `[jest-environment-node]` Fix `--localstorage-file` warning on Node 25+ ([#16086](jestjs/jest#16086))
- `[jest-reporters]` Apply global coverage threshold to unmatched pattern files in addition to glob/path thresholds ([#16137](jestjs/jest#16137))
- `[jest-reporters, jest-runner, jest-runtime, jest-transform]` Fix coverage report not showing correct code coverage when using `projects` config option ([#16140](jestjs/jest#16140))
- `[jest-runtime]` Resolve `expect` and `@jest/expect` from the internal module registry so test-file imports share the same `JestAssertionError` as the global `expect` ([#16130](jestjs/jest#16130))
- `[jest-runtime]` Improve CJS-from-ESM interop: `__esModule`/Babel default unwrap, broader named-export coverage, and shared CJS singleton across importers ([#16050](jestjs/jest#16050))
- `[jest-runtime]` Load `.js` files with ESM syntax but no `"type":"module"` marker as native ESM ([#16050](jestjs/jest#16050))
- `[jest-runtime]` Extend the `.js`-with-ESM-syntax fallback to `require()` on Node v24.9+ - falls back to `require(esm)` when the CJS parser rejects ESM syntax ([#16078](jestjs/jest#16078))
- `[jest-runtime]` Fix deadlocks and double-evaluation in concurrent ESM and wasm imports ([#16050](jestjs/jest#16050))
- `[jest-runtime]` Fix error when `require()` is called after the Jest environment has been torn down ([#15951](jestjs/jest#15951))
- `[jest-runtime]` Fix missing error when `import()` is called after the Jest environment has been torn down ([#16080](jestjs/jest#16080))
- `[jest-runtime]` Fix virtual `unstable_mockModule` registrations not respected in ESM ([#16081](jestjs/jest#16081))
- `[jest-runtime]` Apply `moduleNameMapper` when resolving modules with `require.resolve()` and the `paths` option ([#16135](jestjs/jest#16135))

##### Chore & Maintenance

- `[@jest/fake-timers]` Upgrade `@sinonjs/fake-timers` ([#16139](jestjs/jest#16139))
- `[jest-runtime]` Use synchronous `linkRequests` / `instantiate` for ESM linking on Node v24.9+ ([#16063](jestjs/jest#16063))
renovate Bot added a commit to andrei-picus-tink/auto-renovate that referenced this pull request May 10, 2026
| datasource | package | from   | to     |
| ---------- | ------- | ------ | ------ |
| npm        | jest    | 30.3.0 | 30.4.2 |


## [v30.4.2](https://github.com/jestjs/jest/blob/HEAD/CHANGELOG.md#3042)

##### Fixes

- `[jest-runtime]` Fix named imports from CJS modules whose `module.exports` is a function with own-property exports ([#16150](jestjs/jest#16150))


## [v30.4.1](https://github.com/jestjs/jest/blob/HEAD/CHANGELOG.md#3041)

##### Features

- `[jest-config, jest-core, jest-runner, jest-schemas, jest-types]` Allow custom runner configuration options via tuple format `['runner-path', {options}]` ([#16141](jestjs/jest#16141))

##### Fixes

- `[jest-runtime]` Align CJS-from-ESM default export with Node: `module.exports` is always the ESM default, `__esModule` unwrapping is no longer applied ([#16143](jestjs/jest#16143))


## [v30.4.0](https://github.com/jestjs/jest/blob/HEAD/CHANGELOG.md#3040)

##### Features

- `[babel-jest]` Support collecting coverage from `.mts`, `.cts` (and other) files ([#15994](jestjs/jest#15994))
- `[jest-circus, jest-cli, jest-config, jest-core, jest-jasmine2, jest-types]` Add `--collect-tests` flag to discover and list tests without executing them ([#16006](jestjs/jest#16006))
- `[jest-config, jest-runner, jest-worker]` Add `workerGracefulExitTimeout` config option to control how long workers are given to exit before being force-killed ([#15984](jestjs/jest#15984))
- `[jest-config]` Add support for `jest.config.mts` as a valid configuration file ([#16005](jestjs/jest#16005))
- `[jest-config, jest-core, jest-reporters, jest-runner]` `verbose` and `silent` can now be set per-project; the project-level value overrides the global value for that project's tests ([#16133](jestjs/jest#16133))
- `[@jest/fake-timers]` Accept `Temporal.Duration` in `jest.advanceTimersByTime()` and `jest.advanceTimersByTimeAsync()` ([#16128](jestjs/jest#16128))
- `[@jest/fake-timers]` Accept `Temporal.Instant` and `Temporal.ZonedDateTime` in `jest.setSystemTime()` and `useFakeTimers({now})` ([#16128](jestjs/jest#16128))
- `[@jest/fake-timers]` Support faking `Temporal.Now.*` ([#16131](jestjs/jest#16131))
- `[jest-mock]` Add `clearMocksOnScope(scope)` on `ModuleMocker` for clearing every mock function exposed on a scope object ([#16088](jestjs/jest#16088))
- `[jest-resolve]` Add `canResolveSync()` on `Resolver` so callers can detect when a user-configured resolver only exports an `async` hook ([#16064](jestjs/jest#16064))
- `[jest-runtime]` Use synchronous `evaluate()` for ES modules without top-level `await` on Node versions that support it (v24.9+), and prefer the synchronous transform path when a sync transformer is configured ([#16062](jestjs/jest#16062))
- `[jest-runtime]` Support `require()` of ES modules on Node v24.9+ ([#16074](jestjs/jest#16074))
- `[jest-runtime]` Validate TC39 import attributes (`with { type: 'json' }`) on ESM imports ([#16127](jestjs/jest#16127))
- `[@jest/transform]` Add `canTransformSync(filename)` on `ScriptTransformer` so callers can pick the sync vs async transform path ([#16062](jestjs/jest#16062))
- `[jest-util]` Add `isError` helper ([#16076](jestjs/jest#16076))
- `[pretty-format]` Support React 19 ([#16123](jestjs/jest#16123))

##### Fixes

- `[expect-utils]` Fix `toStrictEqual` failing on `structuredClone` results due to cross-realm constructor mismatch ([#15959](jestjs/jest#15959))
- `[@jest/expect-utils]` Prevent `toMatchObject`/subset matching from throwing when encountering exotic iterables ([#15952](jestjs/jest#15952))
- `[fake-timers]` Convert `Date` to milliseconds before passing to `@sinonjs/fake-timers` ([#16029](jestjs/jest#16029))
- `[jest]` Export `GlobalConfig` and `ProjectConfig` TypeScript types ([#16132](jestjs/jest#16132))
- `[jest-circus]` Prevent crash when `asyncError` is undefined for non-Error throws ([#16003](jestjs/jest#16003))
- `[jest-circus, jest-jasmine2]` Include `Error.cause` in JSON `failureMessages` output ([#15967](jestjs/jest#15967))
- `[jest-config]` Fix preset path resolution on Windows when the preset uses subpath `exports` ([#15961](jestjs/jest#15961))
- `[jest-config]` Allow `collectCoverage` and `coverageProvider` in project config without a validation warning ([#16132](jestjs/jest#16132))
- `[jest-config]` Project config validator now emits "is not supported in an individual project configuration" instead of "probably a typing mistake" for known global-only options ([#16132](jestjs/jest#16132))
- `[jest-environment-node]` Fix `--localstorage-file` warning on Node 25+ ([#16086](jestjs/jest#16086))
- `[jest-reporters]` Apply global coverage threshold to unmatched pattern files in addition to glob/path thresholds ([#16137](jestjs/jest#16137))
- `[jest-reporters, jest-runner, jest-runtime, jest-transform]` Fix coverage report not showing correct code coverage when using `projects` config option ([#16140](jestjs/jest#16140))
- `[jest-runtime]` Resolve `expect` and `@jest/expect` from the internal module registry so test-file imports share the same `JestAssertionError` as the global `expect` ([#16130](jestjs/jest#16130))
- `[jest-runtime]` Improve CJS-from-ESM interop: `__esModule`/Babel default unwrap, broader named-export coverage, and shared CJS singleton across importers ([#16050](jestjs/jest#16050))
- `[jest-runtime]` Load `.js` files with ESM syntax but no `"type":"module"` marker as native ESM ([#16050](jestjs/jest#16050))
- `[jest-runtime]` Extend the `.js`-with-ESM-syntax fallback to `require()` on Node v24.9+ - falls back to `require(esm)` when the CJS parser rejects ESM syntax ([#16078](jestjs/jest#16078))
- `[jest-runtime]` Fix deadlocks and double-evaluation in concurrent ESM and wasm imports ([#16050](jestjs/jest#16050))
- `[jest-runtime]` Fix error when `require()` is called after the Jest environment has been torn down ([#15951](jestjs/jest#15951))
- `[jest-runtime]` Fix missing error when `import()` is called after the Jest environment has been torn down ([#16080](jestjs/jest#16080))
- `[jest-runtime]` Fix virtual `unstable_mockModule` registrations not respected in ESM ([#16081](jestjs/jest#16081))
- `[jest-runtime]` Apply `moduleNameMapper` when resolving modules with `require.resolve()` and the `paths` option ([#16135](jestjs/jest#16135))

##### Chore & Maintenance

- `[@jest/fake-timers]` Upgrade `@sinonjs/fake-timers` ([#16139](jestjs/jest#16139))
- `[jest-runtime]` Use synchronous `linkRequests` / `instantiate` for ESM linking on Node v24.9+ ([#16063](jestjs/jest#16063))
scttcper added a commit to getsentry/sentry that referenced this pull request May 18, 2026
upgrade jest dependencies
https://github.com/jestjs/jest/blob/main/CHANGELOG.md#3040

allows us to remove override from react-is see
jestjs/jest#16123
require(esm) is neat jestjs/jest#16074
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Support require of pure ESM packages

3 participants