-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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]: V8 coverage does not work with native ESM #11891
Comments
I'm also experiencing this on 27.2.1 with --coverage=true --coverageProvider=v8. I didn't check covered lines closely, but uncovered lines are off by ~3 lines it seems. Running through c8 and using --coverage=false on jest, the uncovered line numbers are correct. |
@SimenB The problem is clear. All works well with native ESM files, if the value of Possible fix: check if the module wrapper will be used before assigning the value inside |
Could you push your failing test case somewhere I can take a look? |
Sure. I will send a PR tomorrow. |
Found interesting case while cleaning up. I was trying to include (1.) Babel transformer and Babel based coverage: (2.) Any transformer and V8 based coverage (only It is not ESM related, but still it made me curious. V8 checks if code was executed without inserting counters. Just thinking out loud. There are two kinds of files – the ones which can be consumed directly and the others which have to be transpiled. If source file is transpiled, can V8 provide coverage without having a source map? It is not needed for directly consumed files, but what about the transpiled ones? Possible to try, but lines will not match in many cases. What if V8 coverage would simply grey out transpiled files which do not have coverage (as in (1.))? ”Sorry, it is not possible to provide coverage for this file.” In the other hand, if an executable file has no tests... It is much better idea to keep it red in the report instead of greying out. And might be worth to include a note on Babel / V8 coverage differences in documentation together with #11188. @SimenB Could you confirm if this is expected behaviour? Looks so. I add it to tests like here, right? |
If |
Thanks for a hint. Now I see where |
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. |
Version
27.2.0
Steps to reproduce
As it was mentioned in #9430 (comment), I was trying out V8 coverage with native ESM. Babel coverage works well, but for some reason there are issues with V8 coverage.
I was testing:
@SimenB thanks for quick response and hints. I started from creating failing tests inside a clone of Jest repo. The same result – coverage works well with Babel, but not with V8. So I will dig into the code and will try to find the reason.
Expected behavior
I also tried out coverage using
c8
module directly on an ESM file (without involving Jest). All is good. Quick, nice and precise.Similar result is expected.
Actual behavior
V8 coverage reports seems to be buggy.
Additional context
No response
Environment
The text was updated successfully, but these errors were encountered: