Skip to content

Conversation

manangarg21
Copy link

#15865

##Summary
Problem: In Jest’s VM, process.features.require_module can be true (inherited from Node), causing defensive code to attempt require('./some-esm.js') and throw “Must use import to load ES Module”.

Fix: In packages/jest-util/src/createProcessObject.ts, when creating Jest’s VM process, override process.features.require_module to always return false (if the flag exists). This aligns the flag with Jest’s capabilities so defensive code takes the fallback path.

Scope: Only the VM’s process.features.require_module getter is affected, guarded behind presence checks. No other global behaviors are changed.

Changed files:
packages/jest-util/src/createProcessObject.ts
packages/jest-util/src/tests/installCommonGlobals.test.ts (new assertion added)

##Test plan

Added a test verifying the override:
packages/jest-util/src/tests/installCommonGlobals.test.ts
it('overrides process.features.require_module to false when present', ...)

Commands run and output:
yarn install --immutable
yarn build:ts
yarn build:js

yarn jest packages/jest-util/src/tests/installCommonGlobals.test.ts --color

Output:
PASS packages/jest-util/src/tests/installCommonGlobals.test.ts
✓ returns the passed object (63 ms)
✓ turns a V8 global object into a Node global object (3 ms)
✓ overrides process.features.require_module to false when present (2 ms)

Test Suites: 1 passed, 1 total
Tests: 3 passed, 3 total
Snapshots: 0 total
Time: 0.422 s

Copy link

netlify bot commented Oct 16, 2025

Deploy Preview for jestjs ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 579c4b2
🔍 Latest deploy log https://app.netlify.com/projects/jestjs/deploys/68f103085a091f00087eec97
😎 Deploy Preview https://deploy-preview-15867--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.

Copy link

linux-foundation-easycla bot commented Oct 16, 2025

CLA Signed

The committers listed above are authorized under a signed CLA.

Copy link

pkg-pr-new bot commented Oct 16, 2025

Open in StackBlitz

babel-jest

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

babel-plugin-jest-hoist

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

babel-preset-jest

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

create-jest

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

@jest/diff-sequences

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

expect

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

@jest/expect-utils

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

jest

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

jest-changed-files

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

jest-circus

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

jest-cli

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

jest-config

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

@jest/console

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

@jest/core

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

@jest/create-cache-key-function

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

jest-diff

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

jest-docblock

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

jest-each

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

@jest/environment

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

jest-environment-jsdom

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

@jest/environment-jsdom-abstract

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

jest-environment-node

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

@jest/expect

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

@jest/fake-timers

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

@jest/get-type

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

@jest/globals

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

jest-haste-map

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

jest-jasmine2

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

jest-leak-detector

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

jest-matcher-utils

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

jest-message-util

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

jest-mock

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

@jest/pattern

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

jest-phabricator

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

jest-regex-util

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

@jest/reporters

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

jest-resolve

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

jest-resolve-dependencies

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

jest-runner

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

jest-runtime

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

@jest/schemas

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

jest-snapshot

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

@jest/snapshot-utils

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

@jest/source-map

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

@jest/test-result

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

@jest/test-sequencer

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

@jest/transform

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

@jest/types

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

jest-util

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

jest-validate

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

jest-watcher

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

jest-worker

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

pretty-format

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

commit: 579c4b2

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.

1 participant