-
Notifications
You must be signed in to change notification settings - Fork 27.1k
Closed
Labels
area: compilerIssues related to `ngc`, Angular's template compilerIssues related to `ngc`, Angular's template compilercross-cutting: signals
Milestone
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 AoT enabled produced inaccurate code coverage for branches, with signals (always?) marked as a not tested branch.
For example: input.required<UserModel>(); has <UserModel>() marked as untested (but input.required is marked as tested),
computed(...) or signal(...) have their last parenthesis marked as an untested branch as well.
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 gives:
=============================== Coverage summary ===============================
Statements : 100% ( 5/5 )
Branches : 100% ( 0/0 )
Functions : 100% ( 0/0 )
Lines : 100% ( 3/3 )
================================================================================
Running ng test --no-watch --code-coverage --aot gives:
=============================== Coverage summary ===============================
Statements : 100% ( 50/50 )
Branches : 85.71% ( 6/7 )
Functions : 100% ( 7/7 )
Lines : 100% ( 43/43 )
================================================================================
In coverage/aot-coverage/app.ts.html we can see the last parenthesis of the signal is marked as not tested:
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?
Note that the same happens with the unit-test runner, with Vitest or Karma.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
area: compilerIssues related to `ngc`, Angular's template compilerIssues related to `ngc`, Angular's template compilercross-cutting: signals