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

[Bug]: Document v8 code coverage options #12835

Closed
spenserblack opened this issue May 11, 2022 · 14 comments · Fixed by #12836
Closed

[Bug]: Document v8 code coverage options #12835

spenserblack opened this issue May 11, 2022 · 14 comments · Fixed by #12836

Comments

@spenserblack
Copy link
Contributor

Version

28.1.0

Steps to reproduce

  1. Clone https://github.com/spenserblack/jest-v8-coverage-issue
  2. yarn
  3. yarn test-v8, see that coverage is <100%
  4. yarn test-babel, see that coverage is 100%

Expected behavior

That coverage with the v8 provider would be 100%, because the default switch case is ignored via /* istanbul ignore next */

Actual behavior

/* istanbul ignore next */ seems to be ignored when using the v8 provider.

Additional context

No response

Environment

System:
    OS: Linux 5.4 Ubuntu 20.04.4 LTS (Focal Fossa)
    CPU: (2) x64 Intel(R) Xeon(R) CPU E5-1603 v3 @ 2.80GHz
  Binaries:
    Node: 16.15.0 - /usr/bin/node
    Yarn: 1.22.18 - ~/.yarn/bin/yarn
    npm: 8.3.2 - ~/.npm/bin/npm
  npmPackages:
    jest: ^28.1.0 => 28.1.0
@mrazauskas
Copy link
Contributor

You should use /* c8 ignore next */ comment with v8. See https://github.com/bcoe/c8#ignoring-uncovered-lines-functions-and-blocks

@spenserblack
Copy link
Contributor Author

Thanks for pointing that out! That was a simple mistake on my part 🤦
Closing.

@SimenB
Copy link
Member

SimenB commented May 11, 2022

We should probably mention this in our docs

@spenserblack
Copy link
Contributor Author

Would it be possible to make this more clear in the docs?
My mistake comes from starting with this stackoverflow answer, and viewing the linked documentation mentioning istanbul. A ctrl+f of that same documentation yielded no results of c8.

@SimenB
Copy link
Member

SimenB commented May 11, 2022

wanna send a pr? 🙂

@mrazauskas
Copy link
Contributor

Indeed. Would be really nice to have docs covering difference between babel / v8 coverage.

For the beginning, perhaps a note on ignore comments could be added next to collectcoverage? Or better next to coverageProvider?

@SimenB SimenB reopened this May 11, 2022
@SimenB
Copy link
Member

SimenB commented May 11, 2022

Both, I think. Or at least in coverageProvider, and link to that section from collectCoverage

@spenserblack spenserblack changed the title [Bug]: Using v8 for coverage provider breaks /* istanbul ignore next */ [Bug]: Document v8 code coverage options May 11, 2022
@spenserblack
Copy link
Contributor Author

wanna send a pr?

Just checking if that was addressed to me or @mrazauskas 🙂

@mrazauskas
Copy link
Contributor

Just do it, if that is interesting for you (;

@spenserblack
Copy link
Contributor Author

Sure, I could do that 🙂
I'm guessing this is the file to adjust?
https://github.com/facebook/jest/blob/3b0a975269a3b712d0235f67fbd072dd9cb867b2/docs/Configuration.md?plain=1#L225-L229

I'm a bit worried that a note on ignore comments would be too specific. Perhaps it might be best to just have permalinks istanbul and c8 docs (example)?

@SimenB
Copy link
Member

SimenB commented May 11, 2022

It's non obvious v8 provider needs c8 comments, so I do think it makes sense there

@mrazauskas
Copy link
Contributor

Not sure which place is the best. Might be we all have somewhat different picture in our minds. Just try putting it together and open a PR. It is easier to reason about a real thing.

A general sentence with links should be enough. By the way, this looks like some draft (last bullet) – #11188

@spenserblack
Copy link
Contributor Author

Made PR #12836 😃

@github-actions
Copy link

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.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 13, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants