-
Notifications
You must be signed in to change notification settings - Fork 11.9k
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 tests with AoT enabled with Karma produces a code coverage report that includes the template files, both with the karma builder or the new unit-test builder with Karma as a runner.
But the vitest runner only produces a code coverage report for TS files.
Minimal Reproduction
This can be reproduced in a brand new CLI app.
npx @angular/cli@21.0.0-next.8 new aot-coverage --defaults --no-routing
cd aot-coverage
Running ng test --no-watch --code-coverage --aot gives a report with a coverage/aot-coverage/app.html.html file.
Switch to the unit-test builder with Karma in angular.json:
"test": {
"builder": "@angular/build:unit-test",
"options": {
"runner": "karma"
}Running ng test --no-watch --coverage also gives a report with a coverage/aot-coverage/app.html.html file.
Switch to the vitest runner:
"test": {
"builder": "@angular/build:unit-test",
"options": {
"runner": "vitest"
}Install the missing deps:
npm i --save-dev --save-exact jsdom vitest @vitest/coverage-v8
Running ng test --no-watch --coverage does not give a report with a coverage/aot-coverage/src/app.html.html file (only a coverage/aot-coverage/src/app.ts.html file).
Exception or Error
Your Environment
Angular CLI : 21.0.0-next.8
Angular : 21.0.0-next.8
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.8 │ ^21.0.0-next.8 │
│ @angular/cli │ 21.0.0-next.8 │ ^21.0.0-next.8 │
│ @angular/common │ 21.0.0-next.8 │ ^21.0.0-next.0 │
│ @angular/compiler │ 21.0.0-next.8 │ ^21.0.0-next.0 │
│ @angular/compiler-cli │ 21.0.0-next.8 │ ^21.0.0-next.0 │
│ @angular/core │ 21.0.0-next.8 │ ^21.0.0-next.0 │
│ @angular/forms │ 21.0.0-next.8 │ ^21.0.0-next.0 │
│ @angular/platform-browser │ 21.0.0-next.8 │ ^21.0.0-next.0 │
│ @angular/router │ 21.0.0-next.8 │ ^21.0.0-next.0 │
│ rxjs │ 7.8.2 │ ~7.8.0 │
│ typescript │ 5.9.3 │ ~5.9.2 │
└───────────────────────────┴───────────────────┴───────────────────┘
Anything else relevant?
No response