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

An attempt to fix coverage after updating Jest to 25.2.0 #7896

Conversation

thorn0
Copy link
Member

@thorn0 thorn0 commented Mar 28, 2020

Seems like the coverage wasn't collected because of transform:{} in jest.config.js.
Any idea why we needed this line there? Apparently, it disables the Babel transform, so we probably should disable it conditionally or use coverageProvider: "v8": #7897

closes #7893

@thorn0 thorn0 added the type:infra Issues about CI, publishing to npm, or similar label Mar 28, 2020
@SimenB
Copy link
Contributor

SimenB commented Mar 29, 2020

Hey! This wasn't supposed to change with 25.2. We need Babel (or v8) to instrument code, but that should happen regardless of a transformer being defined or not. It's late here now, but I can investigate tomorrow

@SimenB
Copy link
Contributor

SimenB commented Mar 29, 2020

The issue is this line: https://github.com/facebook/jest/blob/2c666c21c6efc1fcadaf820cc9b47bf0ac10505a/packages/jest-transform/src/ScriptTransformer.ts#L230

Removing it, or forcing it to false, fixes the issue. It was added in jestjs/jest#9460

@thorn0
Copy link
Member Author

thorn0 commented Mar 29, 2020

@SimenB It was late too, I couldn't make sure it's indeed a bug to report. Would you recommend switching to coverageProvider: "v8" on Node 13 or should we stick with Babel for now?

@SimenB
Copy link
Contributor

SimenB commented Mar 29, 2020

The V8 report is faster, while the Babel one is more accurate. I'd take a look at the html report locally and compare them, and decide based on that 🙂

@thorn0
Copy link
Member Author

thorn0 commented Mar 29, 2020

E.g. V8 reports that the line 212 is covered now whereas according to Babel it's not. Whom should I trust? :)

@SimenB
Copy link
Contributor

SimenB commented Mar 29, 2020

It's half red, not sure what that means?
image

In general I'd be more trustful of the Babel report as it has existed for longer and is more well-tested. If you're able to find places where the V8 report is wrong though, an issue would be awesome so we could fix it 👍

@thorn0
Copy link
Member Author

thorn0 commented Mar 29, 2020

These pages compare coverage for two given commits. Half-red means the line was not covered in the older commit but is covered now. The older report in both cases is the same and was generated by Babel.

@SimenB
Copy link
Contributor

SimenB commented Mar 29, 2020

Aha. Probably wrong then 😀 If you could reduce it down and open up a bug report that'd be awesome. Probably something for v8-to-istanbul, but might be the implementation in Jest as well, so let's start there

@thorn0
Copy link
Member Author

thorn0 commented Mar 29, 2020

So, sticking with Babel then.

If you could reduce it down and open up a bug report that'd be awesome.

Added this to my OSS to-do list.

BTW, what should actually mean "covered" in this specific case?

  • "() => false was the result of the conditional operator",
  • "() => false was called",
  • either of the above happened,
  • both?

@SimenB
Copy link
Contributor

SimenB commented Mar 29, 2020

I think ideally covered should mean "both" - coverage should be able to differentiate between "else case in ternary hit" and "function defined was called".

@thorn0
Copy link
Member Author

thorn0 commented Mar 29, 2020

superseded by #7901

Thanks @SimenB !

@thorn0 thorn0 closed this Mar 29, 2020
@thorn0 thorn0 deleted the fix-coverage-after-update-to-jest-25.2.0 branch July 8, 2020 22:30
@fisker fisker mentioned this pull request Feb 3, 2021
4 tasks
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 9, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type:infra Issues about CI, publishing to npm, or similar
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Code coverage failing on PRs
2 participants