jest icon indicating copy to clipboard operation
jest copied to clipboard

[Bug]: `--selectProjects` ignores file path arguments on Windows

Open kbigdelysh opened this issue 2 months ago • 7 comments

Version

29.7.0

Steps to reproduce

  1. Clone the reproduction repository at https://github.com/kbigdelysh/jest-windows-path-bug-reproduction
  2. Install dependencies: pnpm install (or npm install)
  3. Run the command: pnpm run test:specific (or npx jest --selectProjects unit src/__tests__/example-one.test.ts)
  4. Expected: Should run 1 test suite (3 tests) from example-one.test.ts
  5. 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 --selectProjects specifically 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 avatar Oct 27 '25 00:10 kbigdelysh

@kbigdelysh I don't see any test files in the repo for reproduction. Can you help filling in?

hainenber avatar Oct 27 '25 15:10 hainenber

@hainenber Sorry, I forgot to push the files. I've pushed them now. Tests are in src/tests

kbigdelysh avatar Oct 27 '25 15:10 kbigdelysh

I can confirm that this can be reproduced on MacOS as well. The issue is pretty much across all platforms.

hainenber avatar Oct 31 '25 15:10 hainenber

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

Image

hainenber avatar Nov 02 '25 04:11 hainenber

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

kbigdelysh avatar Nov 03 '25 17:11 kbigdelysh

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 😢

hainenber avatar Nov 05 '25 15:11 hainenber

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.

github-actions[bot] avatar Dec 05 '25 16:12 github-actions[bot]