Minimal reproduction of Jest bug where --selectProjects ignores file path arguments on Windows.
- Platform: Windows 10/11
- Node.js: v22.11.0
- Jest: 29.7.0
- Package Manager: pnpm 10.15.0
- Shell: PowerShell
When using --selectProjects with a file path argument on Windows, Jest ignores the file path and runs all tests in the selected project instead of just the specified file.
This is a Jest core issue - the bug occurs regardless of whether you use pnpm, npm, yarn, npx, or run Jest directly via node.
pnpm installpnpm testExpected Output:
Test Suites: 3 passed, 3 total
Tests: 9 passed, 9 total
pnpm run test:specific
# Or manually: jest --selectProjects unit src/__tests__/example-one.test.tsExpected Output:
Test Suites: 1 passed, 1 total
Tests: 3 passed, 3 total
Actual Output (BUG):
Test Suites: 3 passed, 3 total
Tests: 9 passed, 9 total
The file path argument is completely ignored.
pnpm run test:workaround
# Or manually: jest --testPathPattern=example-oneOutput (WORKS):
Test Suites: 1 passed, 1 total
Tests: 3 passed, 3 total
This correctly runs only the specified test file.
The bug occurs regardless of how Jest is invoked:
Via npx:
npx jest --selectProjects unit src/__tests__/example-one.test.tsDirect node execution:
node node_modules/jest/bin/jest.js --selectProjects unit src/__tests__/example-one.test.tsResult for both: All 3 test suites run (BUG) ❌
This confirms the issue is with Jest itself, not with pnpm or any package manager.
The bug demonstrates that --selectProjects ignores file path arguments on Windows, requiring the use of --testPathPattern as a workaround.
This is a Jest core issue that occurs regardless of the execution method (pnpm, npx, or direct node execution).