vitest icon indicating copy to clipboard operation
vitest copied to clipboard

Code Coverage Issue with Istanbul Provider

Open aimad-majdou opened this issue 1 year ago • 15 comments

Describe the bug

I am experiencing an issue with code coverage reporting when using the Istanbul provider. Some files that are exported as default are not marked as covered in the coverage report, even though I have tests for them.

Interestingly, when I add an additional export to these files, they are marked as covered:

Notably, this issue does not occur when I switch to using the V8 provider for code coverage. This behavior seems inconsistent, as other files with only a default export do not require an additional export to get covered.

Reproduction

Check this example: https://stackblitz.com/edit/github-w9fjy7-fjohui

As you can see in image below after the test runs in this example, the file covered.tsx gets covered, but the file notCovered doesn't get covered.

The files and their tests are exactly the same, the only difference is that NotCovered is only exported by a default export, but Covered is exported directly and also by a default export.

Also you can see that the file SubFeature like NotCovered is only exported by a default export, but it gets covered.

image

System Info

System:
    OS: Windows 10 10.0.19045
    CPU: (8) x64 Intel(R) Core(TM) i7-8565U CPU @ 1.80GHz
    Memory: 4.46 GB / 15.86 GB
  Binaries:
    Node: 18.12.1 - C:\Program Files\nodejs\node.EXE     
    npm: 8.19.2 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: Spartan (44.19041.1266.0), Chromium (117.0.2045.41)
  npmPackages:
    @vitejs/plugin-react: 4.0.3 => 4.0.3
    @vitejs/plugin-react-swc: 3.3.2 => 3.3.2
    @vitest/coverage-istanbul: 0.34.2 => 0.34.2
    @vitest/ui: 0.34.1 => 0.34.1
    vite: 4.4.5 => 4.4.5
    vitest: 0.34.3 => 0.34.3

Used Package Manager

npm

Validations

aimad-majdou avatar Sep 26 '23 14:09 aimad-majdou