Version
29.3.1
Steps to reproduce
Minimal repro (incl readme with more details): https://github.com/yegorpetrov/ts-jest-issue-repro/tree/no-eslint
- Use macOS, ubuntu-latest of GitHub or WSL/Ubuntu. May be some other Linux env (did not check) but not Windows.
npm i.
- Check
node node_modules/jest/bin/jest.js --showConfig to see where the cacheDirectory is (e.g. /tmp/jest_rs).
- Empty the cache directory.
- Observe the error:
npm run test yields ReferenceError: exports is not defined in "jest.setup-files.ts".
- Try
npm run test again to see that the error does not go away.
- Navigate to jest.setup-files.ts and make any edit, e.g. insert a meaningless space character.
npm run test again - there is no error anymore
- Clean the cache directory and do
npm run test once more - the error will reappear.
Expected behavior
I expect ts-jest to execute the test without failures and additional manipulations with the cache or the setup file.
Actual behavior
ts-jest reports an ESM error ReferenceError: exports is not defined in a setup file, but only on Linux (WSL or ubuntu-latest in Github runners).
Debug log
ts-jest-win.log
ts-jest-wsl.log
Additional context
No response
Environment
System:
OS: Linux 5.15 Ubuntu 20.04.6 LTS (Focal Fossa) **WSL**
CPU: (12) x64 AMD Ryzen 5 4600H with Radeon Graphics
Binaries:
Node: 22.14.0 - ~/.nvm/versions/node/v22.14.0/bin/node
Yarn: 1.22.10 - /usr/bin/yarn
npm: 10.9.2 - ~/.nvm/versions/node/v22.14.0/bin/npm
npmPackages:
jest: ^29.7.0 => 29.7.0
macOS seems to be affected too.