Demonstrating a misleading error message caused by a missing dependency in a package manager with strict/non-hoisted installation layout.
This repro uses yarn
v4 with nodeLinker: pnpm
, but the same issue would happen with pnpm
itself.
- Clone the repo and
cd
in - Verify
yarn -v
shows 4.1.1 yarn
yarn test
=> observe that tests run but there's an "Invalid testPattern" messageyarn test other
=> observe that all tests run, not only the selected test
The actual issue is that jest-util
is missing a dep on jest-regex-util
(and due to the non-hoisted layout, it's not implicitly present), but the warning message it causes is very misleading:
$ yarn jest
Invalid testPattern supplied. Running all tests instead.
Invalid testPattern supplied. Running all tests instead.
PASS ./other.test.js
PASS ./index.test.js
Test Suites: 2 passed, 2 total
Tests: 2 passed, 2 total
Snapshots: 0 total
Time: 0.346 s, estimated 1 s
Ran all test suites.
$ yarn jest other
Invalid testPattern other supplied. Running all tests instead.
Invalid testPattern other supplied. Running all tests instead.
PASS ./other.test.js
PASS ./index.test.js
Test Suites: 2 passed, 2 total
Tests: 2 passed, 2 total
Snapshots: 0 total
Time: 0.27 s, estimated 1 s
Ran all test suites.