Command
test
Is this a regression?
The previous version in which this bug was not present was
21.0.0-next.8
Description
Since the internal migration to vitest v4, code coverage with Vitest is always 0.
Minimal Reproduction
npx @angular/cli@21.0.0-next.9 new vitest-coverage --defaults --no-routing
cd vitest-coverage
npm i --save-dev @vitest/coverage-v8
Update angular.json:
"test": {
"builder": "@angular/build:unit-test",
"options": {
"coverage": true,
"coverageInclude": ["src/**/*.ts", "src/**/*.html"]
}
}
Launch the tests: ng test --no-watch
Results:
% Coverage report from v8
----------------|---------|----------|---------|---------|-------------------
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
----------------|---------|----------|---------|---------|-------------------
All files | 0 | 100 | 0 | 0 |
src | 0 | 100 | 0 | 0 |
main.ts | 0 | 100 | 0 | 0 | 5-6
src/app | 0 | 100 | 100 | 0 |
app.config.ts | 0 | 100 | 100 | 0 | 3
app.ts | 0 | 100 | 100 | 0 | 9-10
----------------|---------|----------|---------|---------|-------------------
Exception or Error
Your Environment
Angular CLI : 21.0.0-next.9
Angular : 21.0.0-next.9
Node.js : 22.18.0
Package Manager : npm 10.9.0
Operating System : darwin arm64
┌───────────────────────────┬───────────────────┬───────────────────┐
│ Package │ Installed Version │ Requested Version │
├───────────────────────────┼───────────────────┼───────────────────┤
│ @angular/build │ 21.0.0-next.9 │ ^21.0.0-next.9 │
│ @angular/cli │ 21.0.0-next.9 │ ^21.0.0-next.9 │
│ @angular/common │ 21.0.0-next.9 │ ^21.0.0-next.0 │
│ @angular/compiler │ 21.0.0-next.9 │ ^21.0.0-next.0 │
│ @angular/compiler-cli │ 21.0.0-next.9 │ ^21.0.0-next.0 │
│ @angular/core │ 21.0.0-next.9 │ ^21.0.0-next.0 │
│ @angular/forms │ 21.0.0-next.9 │ ^21.0.0-next.0 │
│ @angular/platform-browser │ 21.0.0-next.9 │ ^21.0.0-next.0 │
│ @angular/router │ 21.0.0-next.9 │ ^21.0.0-next.0 │
│ rxjs │ 7.8.2 │ ~7.8.0 │
│ typescript │ 5.9.3 │ ~5.9.2 │
Anything else relevant?
No response
Command
test
Is this a regression?
The previous version in which this bug was not present was
21.0.0-next.8
Description
Since the internal migration to vitest v4, code coverage with Vitest is always 0.
Minimal Reproduction
Update angular.json:
Launch the tests:
ng test --no-watchResults:
Exception or Error
Your Environment
Anything else relevant?
No response