-
-
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
Syntax error when running Jest with coverage and watch (example repo included) #6859
Comments
One minor difference in my observations: I was able to repro with CLI
|
I hate to bump, but this is still happening w/o any traction behind it 3 months later. It seems when I do I'm seeing that if I manually set the Maybe it's finagling its way through |
Just wanted to say that I still have this problem as well. It's not critical in our pipeline so I've just ignored the problem for now, but this should really get fixed. |
My team was having this problem too, even without the
|
I think this bug should be marked as confirmed, I've added a skipped (until fixed) regression e2e test in my fork. It looks like the coverage is being reported on every changed file (even .json files) instead of only the files being tested. |
Thank you! Dug into it, and this comes from #5601, specifically https://github.com/facebook/jest/blob/94c40a5dc5df86b8f27e403bde7fff1e33c74e16/packages/jest-cli/src/SearchSource.js#L171-L179 That Normally https://github.com/facebook/jest/blob/94c40a5dc5df86b8f27e403bde7fff1e33c74e16/packages/jest-cli/src/generateEmptyCoverage.js#L34 would clear it out, but since @stipsan could you take a look? ❤️ A failing test was added to #7611. |
solved this by putting my files in /src/ folder and adding "--collectCoverageFrom=src/**/*.js" so the coverage report won't touch package.json (which likely causes the error in my case) |
@SimenB sure I'll take a look 😄 |
For me the solution was adding the /build folder to the coveragePathIgnorePatterns
because it tries to process the whole file, before making a report 🤣 cheers! |
ignore the files for now "coveragePathIgnorePatterns": [
"/node_modules/",
"package.json"
] |
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
This bug is likely the same as #6258.
In some cases, when I run
jest --coverage --watch
, I get the following error:To Reproduce
Steps to reproduce the behavior:
master
. Reset HEAD to the commit before HEAD ("add package.json and yarn.lock"), but keep the changes, and unstage them. So now you havea.test.js
uncommitted, andpackage.json
has"name": "test"
uncommitted.yarn test-w
. You will get the same error.I assume the cause is because:
coverage
is enabled. It has to be via Jest configcollectCoverage: true
, and not CLI--coverage
.watch
is enabled (and it possibly also occurs withwatch-all
), so only uncommitted changes are watched. In order to reproduce this bug, there needs to be changes to a test file, and changes in a non-JS file, like.eslintrc.json
orpackage.json
.Expected behavior
The error should not happen.
Link to repl or repo (highly encouraged)
The repo is linked to in step 1 of "Reproduce" section above.
Run
npx envinfo --preset jest
Paste the results here:
System: OS: macOS High Sierra 10.13.5 CPU: x64 Intel(R) Core(TM) i7-3615QM CPU @ 2.30GHz Binaries: Node: 8.11.2 - /usr/local/bin/node Yarn: 1.9.4 - /usr/local/bin/yarn npm: 6.4.0 - /usr/local/bin/npm npmPackages: jest: ^23.5.0 => 23.5.0
The bug does not exist in 22.4.4. The bug exists in 23.0.0.
Unfortunately, I can't downgrade to Jest 22 for now, since that version has the
jsdom
errors instead.The text was updated successfully, but these errors were encountered: