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
Repo contains a single test, and a simple Jest config with modulePathIgnorePatterns matching the test file.
npm ci
npm test
Expected behavior
Test is found and is run.
Actual behavior
Test is not even found (0 matches):
> jest
No tests found, exiting with code 1
Run with `--passWithNoTests` to exit with code 0
In C:\dev\mine\jest-bug-module-ignores
3 files checked.
testMatch: **/__tests__/**/*.[jt]s?(x), **/?(*.)+(spec|test).[tj]s?(x) - 0 matches
testPathIgnorePatterns: \\node_modules\\ - 3 matches
testRegex: - 0 matches
Pattern: - 0 matches
Additional context
The docs for modulePathIgnorePatterns state:
An array of regexp pattern strings that are matched against all module paths
before those paths are to be considered 'visible' to the module loader. If a
given module's path matches any of the patterns, it will not be require()-able
in the test environment.
From the above statements, I would expect that all tests are found, and any test without imports/requires would run whereas those with imports/requires of modules matching an ignore pattern would error with a "module not found" message.
Compare to using testPathIgnorePatterns, where we see my test is found but subsequently filtered out:
> jest
No tests found, exiting with code 1
Run with `--passWithNoTests` to exit with code 0
In C:\dev\mine\jest-bug-module-ignores
4 files checked.
testMatch: **/__tests__/**/*.[jt]s?(x), **/?(*.)+(spec|test).[tj]s?(x) - 1 match
testPathIgnorePatterns: C:\\dev\\mine\\jest-bug-module-ignores\\notthese\\ - 3 matches
testRegex: - 0 matches
Pattern: - 0 matches
I would guess this is not a bug at all, just ambiguity in the docs. Can we tighten those up a little, to indicate this behaviour is intentional, that test files are considered modules for the Jest runner? It would also be nice to clarify the difference in behaviour between testPathIgnorePatterns and modulePathIgnorePatterns.
However, in both cases I am confused as to why Jest is reporting THREE matches to the ignore pattern, not one.
This issue was closed because it has been stalled for 30 days with no activity. Please open a new issue if the issue is still relevant, linking to this one.
This issue was closed because it has been stalled for 30 days with no activity. Please open a new issue if the issue is still relevant, linking to this one.
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
29.7
Steps to reproduce
https://github.com/chriswilty/jest-bug-module-ignores
Repo contains a single test, and a simple Jest config with modulePathIgnorePatterns matching the test file.
Expected behavior
Test is found and is run.
Actual behavior
Test is not even found (0 matches):
Additional context
The docs for
modulePathIgnorePatterns
state:From the above statements, I would expect that all tests are found, and any test without imports/requires would run whereas those with imports/requires of modules matching an ignore pattern would error with a "module not found" message.
Compare to using
testPathIgnorePatterns
, where we see my test is found but subsequently filtered out:I would guess this is not a bug at all, just ambiguity in the docs. Can we tighten those up a little, to indicate this behaviour is intentional, that test files are considered modules for the Jest runner? It would also be nice to clarify the difference in behaviour between testPathIgnorePatterns and modulePathIgnorePatterns.
However, in both cases I am confused as to why Jest is reporting THREE matches to the ignore pattern, not one.
Environment
The text was updated successfully, but these errors were encountered: