When run from `jest --coverage`, produces invalid code
See original GitHub issueThe test repo with the error Jest 19.0.2, babel-plugin-istanbul-4.0.0
The error happens to be related to a particular code. Test is passed ok, but when jest
is run with --coverage
, a Syntax Error happens. I made a minimal code example in the buggy
function:
function buggy(stages, cs) {
for (let i = 0; i < stages.length; i++) {
if (cs > i) {
continue;
}
let stage = stages[i];
if (!stage.complete) {
when(() => stage.complete, callback);
break;
}
}
return true;
}
Seems to be a code generation issue.
$ jest --coverage
FAIL ./buggy.test.js
● Test suite failed to run
/Users/max/Documents/projects/bugs_demo/buggy.js:16
} else /* istanbul ignore next */{++cov_2f4l4kc7dh.b[1][1];}};_loop2: for (var i = 0; i < stages.length; i++) {/* istanbul ignore next */var _ret = _loop(i); /* istanbul ignore next */switch (_ret) {case "continue":continue;case "break":break (/* istanbul ignore next */_loop2);}
^
SyntaxError: Unexpected token (
at transformAndBuildScript (node_modules/jest-runtime/build/transform.js:320:12)
at Object.<anonymous> (buggy.test.js:1:115)
Issue Analytics
- State:
- Created 7 years ago
- Comments:10 (4 by maintainers)
Top Results From Across the Web
Why is my Jest code coverage report invalid? - Stack Overflow
I generate the code coverage report with yarn jest --coverage and the application source code is written in JavaScript (rather than TypeScript).
Read more >Configuring code coverage in Jest, the right way
In this brief tutorial we see how to configure code coverage for Jest, the right way.
Read more >Find out how much code you're testing - Angular
When the tests are complete, the command creates a new /coverage folder in the project. Open the index.html file to see a report...
Read more >Snapshot Testing - Jest
Snapshot tests are a very useful tool whenever you want to make sure your UI does not change unexpectedly.
Read more >Code Coverage - Cypress Documentation
If you do want to merge the reports yourself: on every machine running Cypress tests, copy the produced code coverage report into a...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@bcoe this still seems to be an issue. Why was it closed?
I’m having the same issue.