Command
test
Is this a regression?
The previous version in which this bug was not present was
No response
Description
I am in the process of migrating unit tests from Jasmine to Vitest and I noticed that the code coverage percentages are all being thrown off when using Vitest, which did not happen before with Jasmine.
When I run my tests with coverage, the generated report is flagging things like a closing parentheses or a typescript type as an uncovered code branch. This is happening to me when I use either the v8 or istanbul reporter, it seems to make no difference.
I originally opened an issue with Vitest, but they suggested I open one here
Minimal Reproduction
https://stackblitz.com/edit/angular-eslint-repros-pf1h8ams?file=src%2Fmain.ts,src%2Fapp.component.spec.ts
Exception or Error
- Follow above link
- run
npm run test
- Open the code coverage for
main.ts
- You will see lines 16 and 17 show uncovered code branches, which affects the coverage percentage. Obviously this is wrong and I would not expect this to happen
Your Environment
Angular CLI : 21.2.1
Angular : 21.2.1
Node.js : 24.12.0
Package Manager : npm 11.8.0
Operating System : win32 x64
┌───────────────────────────────────┬───────────────────┬───────────────────┐
│ Package │ Installed Version │ Requested Version │
├───────────────────────────────────┼───────────────────┼───────────────────┤
│ @angular/animations │ 21.2.1 │ ^21.2.1 │
│ @angular/build │ 21.2.1 │ ^21.2.1 │
│ @angular/cdk │ 21.2.1 │ ~21.2.1 │
│ @angular/cli │ 21.2.1 │ ^21.2.1 │
│ @angular/common │ 21.2.1 │ ^21.2.1 │
│ @angular/compiler │ 21.2.1 │ ^21.2.1 │
│ @angular/compiler-cli │ 21.2.1 │ ^21.2.1 │
│ @angular/core │ 21.2.1 │ ^21.2.1 │
│ @angular/forms │ 21.2.1 │ ^21.2.1 │
│ @angular/localize │ 21.2.1 │ ^21.2.1 │
│ @angular/platform-browser │ 21.2.1 │ ^21.2.1 │
│ @angular/platform-browser-dynamic │ 21.2.1 │ ^21.2.1 │
│ @angular/router │ 21.2.1 │ ^21.2.1 │
│ vitest │ 4.0.18 │ ^4.0.18 │
│ zone.js │ 0.16.1 │ ~0.16.1 │
└───────────────────────────────────┴───────────────────┴───────────────────┘
Anything else relevant?
No response
Command
test
Is this a regression?
The previous version in which this bug was not present was
No response
Description
I am in the process of migrating unit tests from Jasmine to Vitest and I noticed that the code coverage percentages are all being thrown off when using Vitest, which did not happen before with Jasmine.
When I run my tests with coverage, the generated report is flagging things like a closing parentheses or a typescript type as an uncovered code branch. This is happening to me when I use either the
v8oristanbulreporter, it seems to make no difference.I originally opened an issue with Vitest, but they suggested I open one here
Minimal Reproduction
https://stackblitz.com/edit/angular-eslint-repros-pf1h8ams?file=src%2Fmain.ts,src%2Fapp.component.spec.ts
Exception or Error
npm run testmain.tsYour Environment
Anything else relevant?
No response