Skip to content

Minimal reproduction: Jest --selectProjects ignores file path arguments on Windows (Jest 29.7.0)

kbigdelysh/jest-windows-path-bug-reproduction

Repository files navigation

Jest --selectProjects Windows Bug Reproduction

Minimal reproduction of Jest bug where --selectProjects ignores file path arguments on Windows.

Environment

  • Platform: Windows 10/11
  • Node.js: v22.11.0
  • Jest: 29.7.0
  • Package Manager: pnpm 10.15.0
  • Shell: PowerShell

Issue Description

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.

Setup

pnpm install

Reproduction Steps

1. Run all tests (baseline)

pnpm test

Expected Output:

Test Suites: 3 passed, 3 total
Tests:       9 passed, 9 total

2. Attempt to run a single test file (BUG)

pnpm run test:specific
# Or manually: jest --selectProjects unit src/__tests__/example-one.test.ts

Expected 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.

3. Use workaround with --testPathPattern

pnpm run test:workaround
# Or manually: jest --testPathPattern=example-one

Output (WORKS):

Test Suites: 1 passed, 1 total
Tests:       3 passed, 3 total

This correctly runs only the specified test file.

4. Verify this is a Jest issue (not pnpm/package manager)

The bug occurs regardless of how Jest is invoked:

Via npx:

npx jest --selectProjects unit src/__tests__/example-one.test.ts

Direct node execution:

node node_modules/jest/bin/jest.js --selectProjects unit src/__tests__/example-one.test.ts

Result for both: All 3 test suites run (BUG) ❌

This confirms the issue is with Jest itself, not with pnpm or any package manager.

Conclusion

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).

About

Minimal reproduction: Jest --selectProjects ignores file path arguments on Windows (Jest 29.7.0)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published