Skip to content

When using coverage.all typescript files with no executable code are colored red in the coverage report #3605

@HristoKolev

Description

@HristoKolev

Describe the bug

I have a typescript file that only contains typescript interfaces. When I run vitest with coverage I get it reported as red (uncovered) even when the interfaces are referenced by other files that are covered by tests.

image

The way jest handles this situation is to not count these file as neither covered or uncovered but just empty and colored in gray:

image

Reproduction

Here is the github repo from the images:

https://github.com/HristoKolev/vite-workshop/tree/6549514d7940d642a51aebcfd049466c3cc25e7b

to run it:

cd vite-app

npm i

npm run test

System Info

System:
    OS: Windows 10 10.0.22621
    CPU: (32) x64 AMD Ryzen 9 7950X 16-Core Processor
    Memory: 14.66 GB / 31.16 GB
  Binaries:
    Node: 18.12.1 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.19 - C:\Program Files\nodejs\yarn.CMD
    npm: 9.2.0 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: Spartan (44.22621.1778.0), Chromium (114.0.1823.51)
    Internet Explorer: 11.0.22621.1
  npmPackages:
    @vitejs/plugin-react: ^4.0.0 => 4.0.0
    @vitest/coverage-v8: ^0.32.2 => 0.32.2
    vite: ^4.3.2 => 4.3.9
    vitest: ^0.32.0 => 0.32.2

Used Package Manager

npm

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    feat: coverageIssues and PRs related to the coverage featurep2-to-be-discussedEnhancement under consideration (priority)

    Type

    No type

    Projects

    Status

    P2 - 2

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions