Skip to content
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

fix issue jest 14766 #235

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

fix issue jest 14766 #235

wants to merge 2 commits into from

Conversation

cenfun
Copy link

@cenfun cenfun commented Mar 19, 2024

fix issue jestjs/jest#14766

@@ -13,6 +13,8 @@ class CoverageInstrumenter {
async startInstrumenting() {
this.session.connect();

await this.postSession('Debugger.enable');
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that should be disabled on exit then I assume?

It seems odd to me we need to enable the debugger, tho. any immediate ideas on why?

@cenfun
Copy link
Author

cenfun commented Mar 20, 2024

@SimenB Thanks for the reminder, it has been updated.
The idea originates from Playwright and Puppeteer

But I don't know why, hope someone can explain.

@kristof-mattei
Copy link

I tried to do some research as well as to why this is important. Searching GitHub reveals a whole bunch of places where Debugger.enable is combined with Profiler.enable but a reason in a commit message or so is nowhere to be found.

But to repeat @cenfun's link: https://github.com/puppeteer/puppeteer/blob/88df4075171cdd87ad60241dd77028c96b1a7d9b/packages/puppeteer-core/src/cdp/Coverage.ts#L240-L248

This is code written by the Puppeteer authors themselves (i.e. Google) and the do the same.

I also have a repro if you'd like:

https://github.com/actions-rs-plus/core.

If you clone, npm i etc and then do JEST_JUNIT_OUTPUT_DIR=reports/ JEST_JUNIT_OUTPUT_NAME=unit-tests-report.xml npm run test:ci -- --runInBand --coverage you'll see missed lines.

Apply the patch above in node_modules/collect-v8-coverage and all jumps back to 100%.

kristof-mattei added a commit to actions-rs-plus/core that referenced this pull request Jun 16, 2024
kristof-mattei added a commit to actions-rs-plus/clippy-check that referenced this pull request Jun 16, 2024
kristof-mattei added a commit to actions-rs-plus/clippy-check that referenced this pull request Jun 16, 2024
@HarelM
Copy link

HarelM commented Jun 21, 2024

@SimenB is there anything preventing this from being merged? Can I help in any way to push this forward?

@D4N14L
Copy link

D4N14L commented Jun 24, 2024

@HarelM I can't speak for Simen, but in our own internal repositories we tried to implement this patch ourselves, and while it worked and fixed coverage reporting for us, it caused steep performance regressions in Jest.

@mudcovered
Copy link

@HarelM I can't speak for Simen, but in our own internal repositories we tried to implement this patch ourselves, and while it worked and fixed coverage reporting for us, it caused steep performance regressions in Jest.

What good is performance if the data produced is garbage. I'd rather have my tests run slower and have accurate results than faster tests with coverage that is meaningless.

@D4N14L
Copy link

D4N14L commented Sep 29, 2024

@mudcovered sure, but, respectfully, why not expect both? Performance and correctness were once possible. Why not now? Also FWIW, you can take a less impactful hit to performance if you use the Babel coverage provider, which absolutely shouldn't be necessary if you already have transpiled JavaScript.

It's completely reasonable to expect better from an industry standard testing framework, especially since Node 18 is currently in maintenance mode and will be out of support come April.

@raphaelboukara
Copy link

raphaelboukara commented Oct 31, 2024

Hi @SimenB
Is there a decision to merge this one actually? Or we have to find for another solution?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants