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
Coverage report fails with puppeteer evaluate code #7962
Comments
If I understand correctly, you want |
Hi @jeysal, The test cases fail because the variable tracking in the code coverage software go out of scope I think. Therefore my test cases fail while they do succeed without the code coverage flag. Is it even possible to save the inner part of page.evaluate in another file? |
Oh, now I see what you mean. I didn't understand that the actual test result differed depending on whether coverage is enabled (and I couldn't reproduce it on my Linux machine because I got a different error - but on my Mac I can see the behavior you're describing) |
Could something like https://github.com/istanbuljs/puppeteer-to-istanbul perhaps solve your issue? |
I'm having the same issue and unfortunately puppeteer-to-istanbul had no effect. Best option for now might to be to isolate the page.evaluate call into a separate file and selectively disable coverage for that file by using |
This worked for me, thanks! Took me way too long to figure out the problem was with Jest, rather than Puppeteer or being related to my test being in TypeScript. Will see if I can edit https://jestjs.io/docs/en/puppeteer to add a disclaimer. |
I have also encountered this same issue when working with PouchDB where indexes are written in JS and stringified into the database. The views are evaluated in a sandbox where the coverage collectors aren't defined. See pouchdb/pouchdb#8129 We've resorted to ignoring the file from coverage which works, but isn't ideal. |
Is there any resolution to this issue sooner? |
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 14 days. |
This issue was closed because it has been stalled for 7 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
Code coverage fails to evaluate code that is evaluated in another environment.
To Reproduce
Steps to reproduce the behaviour:
Expected behaviour
Proper coverage report with the puppeteer evaluate code excluded. Otherwise some kind of configuration option to exclude remotely executed code.
jest PASS ./test.js ✓ testing puppeteer page scrape (1144ms) Test Suites: 1 passed, 1 total Tests: 1 passed, 1 total Snapshots: 0 total Time: 3.653s Ran all test suites.
Current behaviour
Link to repl or repo (highly encouraged)
https://github.com/sab24/jestexample
Run by typing
npm i
jest
jest --coverage
Run
npx envinfo --preset jest
Paste the results here:
System: OS: macOS 10.14.2 CPU: (8) x64 Intel(R) Core(TM) i7-7820HQ CPU @ 2.90GHz Binaries: Node: 11.9.0 - /usr/local/bin/node npm: 6.8.0 - /usr/local/bin/npm npmPackages: jest: ^24.1.0 => 24.1.0
The text was updated successfully, but these errors were encountered: