Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

vitest: code coverage is always 0 (and is slow) #30557

@cexbrayat

Description

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

Running ng test with codeCoverage enabled generates reports with 0% coverage out of the box.

Minimal Reproduction

Generate a new app:

npx @angular/cli@20.1.0-next.2 new vitest-coverage --no-routing --defaults
cd vitest-coverage
npm install vitest jsdom @vitest/coverage-v8 --save-dev

Use the unit-test builder:

"test": {
 "builder": "@angular/build:unit-test",
 "options": {
 "tsConfig": "tsconfig.spec.json",
 "buildTarget": "::development",
 "runner": "vitest",
 "codeCoverage": true
 }
}

Run ng test --no-watch

Exception or Error

% Coverage report from v8
----------------|---------|----------|---------|---------|-------------------
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s 
----------------|---------|----------|---------|---------|-------------------
All files | 0 | 0 | 0 | 0 | 
 src | 0 | 0 | 0 | 0 | 
 main.ts | 0 | 0 | 0 | 0 | 1-6 
 src/app | 0 | 0 | 0 | 0 | 
 app.config.ts | 0 | 0 | 0 | 0 | 1-9 
 app.ts | 0 | 0 | 0 | 0 | 1-11 
----------------|---------|----------|---------|---------|-------------------

Your Environment

Angular CLI: 20.1.0-next.2
Node: 22.14.0
Package Manager: npm 10.9.0
OS: darwin arm64
Angular: 20.1.0-next.1
... common, compiler, compiler-cli, core, forms
... platform-browser, router
Package Version
------------------------------------------------------
@angular-devkit/architect 0.2001.0-next.2
@angular-devkit/core 20.1.0-next.2
@angular-devkit/schematics 20.1.0-next.2
@angular/build 20.1.0-next.2
@angular/cli 20.1.0-next.2
@schematics/angular 20.1.0-next.2
rxjs 7.8.2
typescript 5.8.3
zone.js 0.15.1

Anything else relevant?

Two additional points:

  • computing the coverage is very slow
  • the template files aren't included whereas they should as it runs in AoT mode

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

        AltStyle によって変換されたページ (->オリジナル) /