Skip to content

Vitest code coverage not properly reported #30333

@json-derulo

Description

@json-derulo

Command

test

Is this a regression?

  • Yes, this behavior used to work in the previous version

The previous version in which this bug was not present was

No response

Description

I am trying out the new experimental vitest builder, which works great for me in general! I just found an issue with the coverage reporting. After installing @vitest/coverage-v8 and running ng test --code-coverage with the vitest builder, the coverage is not properly reported. The displayed coverage table appears empty:

Image

The XML, JSON and HTML reports located in dist/test-out/**/coverage are also empty. As there is actually something tested in app.ts, I would have expected something to appear in the coverage report.

Minimal Reproduction

  1. Generate a fresh project with npx@angular/cli@next new and switch to the unit-test builder, or check out the code from the reproduction repo: https://github.com/json-derulo/ng20-vitest
  2. Run ng test --code-coverage
  3. Take a look at the console output

Exception or Error

No exception or error visible, but the coverage is not reported

Your Environment

Angular CLI: 20.0.0-rc.2
Node: 22.15.1
Package Manager: pnpm 9.15.6
OS: darwin x64

Angular: 20.0.0-rc.1
... common, compiler, compiler-cli, core, forms
... platform-browser, router

Package                      Version
------------------------------------------------------
@angular-devkit/architect    0.2000.0-rc.2 (cli-only)
@angular-devkit/core         20.0.0-rc.2 (cli-only)
@angular-devkit/schematics   20.0.0-rc.2 (cli-only)
@angular/build               20.0.0-rc.2
@angular/cli                 20.0.0-rc.2
@schematics/angular          20.0.0-rc.2 (cli-only)
rxjs                         7.8.2
typescript                   5.8.3

Anything else relevant?

I also tried to configure the development configuration as the build target for the unit tests, but the same thing happens.

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions