[Bug]: `--selectProjects` ignores file path arguments on Windows
Version
29.7.0
Steps to reproduce
- Clone the reproduction repository at https://github.com/kbigdelysh/jest-windows-path-bug-reproduction
- Install dependencies:
pnpm install(ornpm install) - Run the command:
pnpm run test:specific(ornpx jest --selectProjects unit src/__tests__/example-one.test.ts) - Expected: Should run 1 test suite (3 tests) from
example-one.test.ts - Actual: Runs all 3 test suites (9 tests) - the file path argument is completely ignored
Additional verification:
- Running
pnpm run test:workaround(uses--testPathPattern=example-one) correctly runs only 1 test suite - This confirms
--selectProjectsspecifically ignores file path arguments on Windows
Environment: Windows 10/11, Jest 29.7.0, Node.js v22.11.0, PowerShell
Expected behavior
Expected: Should run 1 test suite (3 tests) from example-one.test.ts
Actual behavior
Actual: Runs all 3 test suites (9 tests) - the file path argument is completely ignored
Additional context
No response
Environment
System:
OS: Windows 11 10.0.26100
CPU: (12) x64 Intel(R) Core(TM) i7-10750H CPU @ 2.60GHz
Binaries:
Node: 22.11.0 - C:\Program Files\nodejs\node.EXE
npm: 10.9.0 - C:\Program Files\nodejs\npm.CMD
pnpm: 9.13.0 - C:\Users\shaml\AppData\Roaming\npm\pnpm.CMD
npmPackages:
jest: ^29.7.0 => 29.7.0
@kbigdelysh I don't see any test files in the repo for reproduction. Can you help filling in?
@hainenber Sorry, I forgot to push the files. I've pushed them now. Tests are in src/tests
I can confirm that this can be reproduced on MacOS as well. The issue is pretty much across all platforms.
@kbigdelysh I start to think this isn't a bug per se but rather how arguments and inputs are parsed and processed in best effort.
If you change the argument ordering, it works as expected. It's gonna be hard to distinguish between input for jest command and input for --selectProjects arguments.
@hainenber I see. Interesting. I'm wondering what can we do to prevent this usability issue for users? Should the Jest team update the docs to reflect this subtle order of arguments? if we don't do something, other people keep encountering this issue. Thanks.
Yes, I agree wholeheartedly. Let me clean up this potential booby trap. Having said that, new doc change may arrives slower than usual as lately Jest folks aren't really active 😢
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days.