vitest
vitest copied to clipboard
Istanbul code coverage differs from nyc result
Describe the bug
I tried running Vitest + Istanbul and the result seems to differ from using Istanbul (+ Mocha, but I also tried Cypress) itself.
- Vitest seems to output a Linux-style path for coverage-final.json, even when running on Windows, this breaks NYC merge
- The branch coverage seems to differ
- (_coverageSchema, hash, contentHash are missing, but they are probably not important)
First image: Mocha + NYC, second image: Vitest
I'm not 100% sure if this a Istanbul or Vitest issue
Reproduction
https://github.com/marvin-j97/vitest-windows-path
(I also have a more complex repo trying to merge Vitest + Cypress Typescript coverage reports: https://github.com/marvin-j97/good-next-template/tree/dev)
System Info
System:
OS: Windows 10 10.0.19044
CPU: (8) x64 Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz
Memory: 8.75 GB / 15.96 GB
Binaries:
Node: 16.14.2 - C:\Program Files\nodejs\node.EXE
Yarn: 1.22.18 - ~\AppData\Roaming\npm\yarn.CMD
npm: 8.5.0 - C:\Program Files\nodejs\npm.CMD
Browsers:
Edge: Spartan (44.19041.1266.0), Chromium (104.0.1293.54)
Internet Explorer: 11.0.19041.1566
npmPackages:
vitest: 0.22.1 => 0.22.1
Used Package Manager
yarn
Validations
- [X] Follow our Code of Conduct
- [X] Read the Contributing Guidelines.
- [X] Read the docs.
- [X] Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- [X] Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- [X] The provided reproduction is a minimal reproducible example of the bug.
The branch coverage seems to differ
I think vitest report is correct.
Only one branch(if at line 2~4) exists [am i right?]
this branch could not be reached. So the result is 0/1
compare branchMap
of coverage-final.json, you will find same if branch is repeated twice in mocha and only one in vitest.
I guess Istanbul is doing "exclude" on branch report so the mocha result is 1/2