vitest icon indicating copy to clipboard operation
vitest copied to clipboard

Istanbul code coverage differs from nyc result

Open marvin-j97 opened this issue 2 years ago • 1 comments

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)

image image 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

marvin-j97 avatar Aug 19 '22 16:08 marvin-j97

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

azaleta avatar Aug 25 '22 07:08 azaleta