Version
29.7.0
Steps to reproduce
Node: 22.13.1 (LTS)
Create a brand-new tiny project:
- npm init -y
- npm install --save-dev jest@latest
- npm install jest-environment-jsdom
- echo "module.exports = { testEnvironment: 'jsdom', globals: { fetch: globalThis.fetch } };" > jest.config.js
- make two files fetch1.test.js and fetch2.test.js with exactly same code:
// fetch.test.js
beforeAll(() => {
console.log(`PID: ${process.pid}, typeof globalThis.fetch = ${typeof globalThis.fetch}`);
});
test('fetch presence', () => {
expect(typeof fetch).toBe('function');
});
-
add "test: jest" to package.json
-
npm run test
- Running in Windows (it works just fine) ✅
- Running in Linux: Ubuntu (it fails) ❌
- npm run test -- --runInBand
- Running in Windows (it works just fine) ✅
- Running in Linux: Ubuntu (it works just fine) ✅
Expected behavior
It should run independently of the OS or parallelization. It appears that the child process does not get the full parent context when running in Linux.
Actual behavior
- npm run test
- Running in Windows (it works just fine) ✅

- Running in Linux: Ubuntu (it fails) ❌

- npm run test -- --runInBand
- Running in Windows (it works just fine) ✅

- Running in Linux: Ubuntu (it works just fine) ✅

Additional context
No response
Environment
System:
Windows 11 and Linux Ubuntu (22.04.3)