istanbuljs / v8-to-istanbul

convert from v8 coverage format to istanbul's format
ISC License
114 stars 41 forks source link

Merging multiple converted coverage reports together for the same file results in a mismatch between the number of properties in `branchMap` and `b`. #158

Open JustinChristensen opened 3 years ago

JustinChristensen commented 3 years ago

I'm not really sure what the expected behavior here should be. I'm using Playwright to run tests and extract coverage reports from V8 for the same test run, and to then convert and merge them together using a coverage map (from istanbul-lib-coverage). .

v8-to-istanbul appears to only have branches that were covered in the v8 coverage report in it's branchMap. This causes the final merged coverage map to have a mismatch between the number of branches in the branchMap and the b hit counters, because of the way that FileCoverage merge is written.

Whether this should be fixed by making that merge routine (mentioned in the linked issue) smarter, or making v8toistanbul attempt to get all (including uncovered branches) in the branchMap for a given file, I can't say for sure.

bcoe commented 3 years ago

@JustinChristensen one problem is that v8 output won't necessarily have all the same branch information, as it collapses together consecutive blocks.

I think this problem might be better solved by merging together the reports while they're in v8 format, which is what happens here.

The conversion from v8 to istanbul is a bit lossy (due to the merging) so I think it's challenging to solve at that layer.