You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You can see the missing dependency by looking at the code: jest-util uses jest-regex-util as shown below, but it's not listed in jest-util/package.json.
That code will work when using a package manager/linker that uses a hoisted node_modules layout, but it will fail to find the implicit dependency with a strict/non-hoisted installation layout, such as yarn v3/4 with nodeLinker: pnpm, pnpm itself, or probably Yarn PnP.
Repro steps to see the misleading error message caused by this issue + non-hoisted installation:
yarn jest => observe that tests run but there's an "Invalid testPattern" message as shown below
yarn jest other => observe that all tests run, not only the selected test
Expected behavior
The tests pass with no odd error messages.
Actual behavior
Running all tests works, but there's a message Invalid testPattern supplied. Running all tests instead.
Trying to filter tests still runs all tests, with the same error message.
$ 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.
Additional context
Debugging into the code shows that the Invalid testPattern log comes from this code block in jest-config, which catches the error (in this case a module not found error) and assumes it's an invalid pattern. The root issue is the missing dependency, but the error handling here could be improved too (not assuming all errors are invalid patterns).
Just open a PR adding jest-regex-util as a dependency to jest/packages/jest-util/package.json. It is obviously missing. Got overlook in #12519, this is what happens naturally with large PRs.
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.
Version
30.0.0-alpha.3 (doesn't repro in 29)
Steps to reproduce
You can see the missing dependency by looking at the code:
jest-util
usesjest-regex-util
as shown below, but it's not listed injest-util/package.json
.jest/packages/jest-util/src/TestPathPatterns.ts
Line 9 in 1d682f2
That code will work when using a package manager/linker that uses a hoisted
node_modules
layout, but it will fail to find the implicit dependency with a strict/non-hoisted installation layout, such asyarn
v3/4 withnodeLinker: pnpm
,pnpm
itself, or probably Yarn PnP.Repro steps to see the misleading error message caused by this issue + non-hoisted installation:
yarn
+nodeLinker: pnpm
setting, orpnpm
)yarn -v
shows 4.1.1yarn
yarn jest
=> observe that tests run but there's an "Invalid testPattern" message as shown belowyarn jest other
=> observe that all tests run, not only the selected testExpected behavior
The tests pass with no odd error messages.
Actual behavior
Invalid testPattern supplied. Running all tests instead.
Additional context
Debugging into the code shows that the
Invalid testPattern
log comes from this code block injest-config
, which catches the error (in this case a module not found error) and assumes it's an invalid pattern. The root issue is the missing dependency, but the error handling here could be improved too (not assuming all errors are invalid patterns).jest/packages/jest-config/src/normalize.ts
Lines 412 to 421 in 1d682f2
Environment
The text was updated successfully, but these errors were encountered: