Merging coverage files doesn't produce accurate cumulative result
See original GitHub issueI execute the following nyc commands, after generating individual coverage reports on the same codebase using different test executions run by Jest and Cypress.
nyc merge coverage-jest combined/coverage-jest.json
nyc merge coverage-cypress combined/coverage-cypress.json
nyc report combined --reporter html --reporter text
Expected Behavior
I’d expect this to show a correct cumulative coverage report of .ts and .html files.
Observed Behavior
- Coverage of .html files is not shown in merged report, while they are show in individial report.
- Coverage of some .ts files is shown correctly, but for others a
Cannot read property 'locations' of undefined
TypeError
is shown.
Troubleshooting steps
- still occurring when I put
cache: false
in my nyc config
Environment Information
System:
OS: Windows 10 10.0.18363
CPU: (8) x64 Intel(R) Core(TM) i7-7700 CPU @ 3.60GHz
Memory: 7.97 GB / 31.88 GB
Binaries:
Node: 13.6.0 - C:\Program Files\nodejs\node.EXE
Yarn: 1.22.0 - C:\Program Files\nodejs\yarn.CMD
npm: 6.13.4 - C:\Program Files\nodejs\npm.CMD
npmPackages:
istanbul-instrumenter-loader: 1.2.0 => 1.2.0
istanbul-lib-coverage: 1.2.1 => 1.2.1
nyc: ^15.0.1 => 15.0.1
source-map-support: ^0.5.16 => 0.5.16
ts-node: ^7.0.1 => 7.0.1
typescript: ~3.7.4 => 3.7.5
For Cypress coverage I use above dependencies as well as @cypress/code-coverage:^3.0.2
.
I’m using jest: 24.1.0
to produce unit test coverage.
Issue Analytics
- State:
- Created 3 years ago
- Comments:15 (1 by maintainers)
Top Results From Across the Web
Merging coverage files doesn't produce accurate cumulative result -
I execute the following nyc commands, after generating individual coverage reports on the same codebase using different test executions run by Jest and ......
Read more >How can I combine multiple single run coverage results into a ...
I my coverage forlder for my model i now have a large number of .cvt coverage data files that I would like to...
Read more >Combine cobertura code coverage reports of three separate ...
The Cobertura Ant library has a merge task that can merge a number of .ser files (generated by the runtime execution of your...
Read more >Questions and Answers on Employer Shared Responsibility ...
Find answers to commonly asked questions about employer shared responsibility provisions under the Affordable Care Act (ACA).
Read more >Merge Jacoco coverage reports for multiproject setups
When using the Gradle JaCoCo plugin, it would be nice if the coverage reports for all subprojects were merged together, to make them...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’m experiencing this same problem.
My coverage results look like so:
cypress/coverage-final.json
:jest/coverage-final.json
:The expected outcome would be
path/to/file.ts
having 100% coverage, since the gaps on one test are covered by the other test. However, instead, what you see is the gaps being reported:combined/coverage-final.json
:The “coverage” merge is really just concatenated instead of merging.
It appears that:
line 1 characters 1-10 uncovered
+line 1 characters 1-5 covered
+line 1 characters 5-10 covered
=line 1 characters 1-10 uncovered
(wrong) +line 1 characters 1-10 covered
(right).The uncovered characters are still shown as uncovered even though their character-span is covered by a different part of the map. Just guessing.
Here is a nice visual LCOV report for the above JSON:
Cypress (fully covered except for 1 branch):
Jest (specifically covering the above branch):
Combined report (expected to be fully covered):
Any advice to unblock this? I don’t want to have to write a JSON merger manually. 😓
Maybe this is just a weird issue with TypeScript.
Below, how are imports and exports not covered? The
export
statement isn’t covered, but the inside of the function somehow is. The inside references an import, but the import isn’t covered. Nonsensical. 😵@D0rmouse did you finally find a good configuration to combine multiple coverage reports?
I have the same type of stack with Nx + Cypress + Storybook + Jest, generating reports separately works fine but when I want to merge, it is not good.
It makes sense because each tool are using different versions for each generation.