-
Notifications
You must be signed in to change notification settings - Fork 91
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
c8 Code Coverage Displaying Code Misses on Multi-line Comments #515
Comments
I am unable to reproduce this missing coverage with a simple isolated case: https://github.com/bcoe/c8-515 Is remix perhaps performing some bundling? |
@eliatcodecov digging a bit more, the issue appears to be cropping up for a file that has not been exercised by a test. When a file isn't run, if the emptyReports.push({
scriptId: 0,
url: resolve(fullPath),
functions: [{
functionName: '(empty-report)',
ranges: [{
startOffset: 0,
endOffset: stat.size,
count: 0
}],
isBlockCoverage: true
}]
}) I'm curious what behaviour you were expecting?
This behaviour seems like a bug to me, I'll see if I can get to the bottom of it. |
It's possible that the |
The issue you're encountering seems to be related to v8-to-istanbul.
Previously, we also used v8-to-istanbul, but faced some issues which you can see here. As no resolution for this problem was found, we implemented our own converter instead of v8-to-istanbul, aiming to rectify these issues. You can find our project here: monocart-coverage-reports. Let's use https://github.com/bcoe/c8-515 as the example to see a comparison of the results.
Comparison of results from lcov: |
The |
@AriPerkkio I was looking at @cenfun is probably correct that there's issues with how source-maps are applied, but I don't think this is what's happening in this case, it seems related to the With regards to the output shared... Looking through old issues, it looks like I was aware of this issue #182, but have just never prioritized the work to implement the functionality (of skipping comment blocks). I'd like to start by digging into the branch discrepancy described in this issue, and then am open to addressing #182 (since it sounds like a few folks are excited to see this functionality). |
@bcoe Thanks for the feedback.
I want to provide an example to explain the issue about the comment lines and blank lines. if (false)
console.log("uncovered") No doubt, the line coverage of the above code is 50%. |
(Note that the reported issue below was encountered in CI on github action's
ubuntu-latest
(the ci.yaml used). I'm not directly sure what version of Node is packaged with github action'subuntu-latest
, but I'll try to find out.)ubuntu-latest
image on GitHub Actions.Greetings from Codecov! Recently we've encountered some strange reporting using the v8 (i.e., c8) reporter in vitest that I wanted to surface as an Issue for your consideration.
It seems like multiline comments are are showing up as coverage misses. Additionally, it seems like -- in some cases -- the first line of these multi-line comments is counted as a conditional false (an uncovered branch in other words). You can see precisely what this looks like on Codecov for this commit.
Note the addition of the license comment in the diff and how Codecov is reporting as fully uncovered.
We can see v8 as the coverage reporter in the vitest config of the repo here
I dug into the raw uploaded reports a bit (the can be downloaded from the Uploads sidebar here). And this is clearly an issue with the coverage output itself and not Codecov directly. Here's a snippet of the output for the tracker.js file at SHA
250b1b2
:In the above xml output you can clearly see the conditional false reporting on line 1 as well as the multiple coverage misses for the multiline comment itself. I'm not sure if the issue is with the clover based XML output, or something more fundamental, but thought I'd surface it here since the example that led to the misreported coverage is so straightforward. If there's anything else you need, please let me know. Thanks!
The text was updated successfully, but these errors were encountered: