-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
--testPathPattern should only match relative path #8226
Comments
Right now
Reason being, only osx has '/Users' Edit: |
A more generic approach would be to use a relative path. const path = require('path');
isMatch: p => regex.test(path.relative(basePath, p))
|
Edit: I've had some time to take a look at this and it's not so straight forward. Technically, any filenames or paths you pass as arguments to jest-cli becomes a regex which then gets tested against the absolute path to the test file. I've realized that the following are equivalent in what they do. jest ./custom.test.js
jest --testPathPattern=./custom.test.js
I find it to be confusing. @SimenB I guess this should also be included in #7185 |
I'm not sure what the desired behavior here would be. For example, right now I sometimes use |
This issue is actually more complicated than I anticipated.
|
I ran into the same problem, we were able to get around this by setting the rootDir in the jest.config.js file. It's sub optimal, but it works.
|
This is a big problem. Common folders to match using This has happened to me multiple times already under different circumstances. Using gopath for all your projects has this issue especially, because of the |
This is what really fixed the test run in the end. For details: jestjs/jest#8226
* Ignore test and test data files from babel This was one of the ways of fixing the jest issue, to avoid having test files under the dist package. It did not fix it completely because we still have a `test.js` file on the root of the package (lmk if we should remove it too) It also doesn't fix the root cause of the issue, which I found later. * Fix test files regex sent as jest argument This is what really fixed the test run in the end. For details: jestjs/jest#8226 * Create coverage script in api package.json Simply calls the regular test with an additional arg. This makes the root `yarn coverage` start working again, since it looks for a script with that exact name in the internal packages. * Fix swagger schema tags descriptions This is unrelated to the other changes but really small so I felt I could just include it here. Just what seems like a typo having the tags with inverted descriptions. * Fix build: revert rm of --help on docker:build validation I probably removed it in some of my tests and actually forgot to undo it later. This is was what was breaking the build since it tried to really run the API and didn't manage to reach the postgresql running locally.
Here is a workaround worked for me. |
This issue is stale because it has been open for 1 year with no activity. Remove stale label or comment or this will be closed in 30 days. |
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. |
🐛 Bug Report
When running tests with
--testPathPattern
it should match only the relative path to the project root. Currently, it matches the full path.It's not usefull to match the full path because all tests have a common prefix.
To Reproduce
Checkout my repo to directory like
/users/<name>/my-project
and runExample:
Expected behavior
it should match only the relative path.
Instead matching
it should match
Link to repl or repo (highly encouraged)
https://github.com/BetterCallSky/jest-test-path-pattern-bug
Run
npx envinfo --preset jest
Paste the results here:
The text was updated successfully, but these errors were encountered: