GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Inaccurate code coverage with aot testing · Issue #64583 · angular/angular

Inaccurate code coverage with aot testing #64583

New issue
Copy link
New issue
Copy link
Closed
#67339
Closed
Inaccurate code coverage with aot testing#64583
#67339
Copy link
Labels
area: compilerIssues related to `ngc`, Angular's template compilerIssues related to `ngc`, Angular's template compilercross-cutting: signals
Milestone
needsTriage

Description

@cexbrayat
cexbrayat
opened on Oct 22, 2025
Issue body actions

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/[email protected] 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:

Image

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.

Reacted by Ken, rexsuecia, AndreasGartmyr, Loïc Chau and Jeroen Akkerman

Activity

  1. cexbrayat
    changed the title [-]Inaccurate code coverage ith aot testing[/-] [+]Inaccurate code coverage with aot testing[/+] on Oct 22, 2025
  2. clydin commented on Oct 22, 2025

    @clydin
    clydin
    on Oct 22, 2025
    Member
    More actions

    Most likely cause is the signalMetadataTransform located here in the Angular compiler:

    angular/packages/compiler-cli/src/ngtsc/transform/src/implicit_signal_debug_name_transform.ts

    Line 478 in 9126d0d

    export function signalMetadataTransform(program: ts.Program): ts.TransformerFactory<ts.SourceFile> {

    Transferring to the framework repo for further triage.

  3. clydin
    transferred this issue fromangular/angular-clion Oct 22, 2025
  4. thePunderWoman
    added
    area: coreIssues related to the framework runtimeIssues related to the framework runtime
    cross-cutting: signals
    on Oct 22, 2025
  5. ngbot
    added this to the needsTriage milestone on Oct 22, 2025
  6. JeanMeche
    added
    area: compilerIssues related to `ngc`, Angular's template compilerIssues related to `ngc`, Angular's template compiler
    and removed
    area: coreIssues related to the framework runtimeIssues related to the framework runtime
    on Oct 23, 2025
  7. JeanMeche commented on Oct 23, 2025

    @JeanMeche
    JeanMeche
    on Oct 23, 2025
    Member
    More actions

    I'm seeing that we apply the transform unconditionnaly. This raises 2 issues

    • It applied even in prod mode, but DCE takes care of removing all the code we generate (this is sub optimal)
    • We should probably only enable it for runtime only dev mode.
  8. dgp1130 commented on Oct 27, 2025

    @dgp1130
    dgp1130
    on Oct 27, 2025
    Contributor
    More actions

    I'm assuming the issue here is that we're effectively generating a conditional on ngDevMode along the lines of ngDevMode ? 'someDebugName' : undefined. Since testing only runs with ngDevMode === true, the false part of this branch is never executed, triggering coverage with weird line numbers, since this isn't present in source code.

    We could disable the transform for ng test, but this is not trivial to do in google3, since we share a single emit format for both testing and non-testing use cases, so we can't easily determine when to enable / disable this transform.

    I think the better solution is likely to continue to always use this transform but then include some kind of ignore comment telling the coverage tool to ignore the false conditional. c8 seems to support an ignore statement and I vaguely recall some kind of LCOV_IGNORE directive? Not sure of the full matrix of support coverage tools and their opt-outs to know how viable this really is.

  9. alan-agius4
    marked Vitest coverage branches false reports angular-cli#31644 as a duplicate of this issue on Oct 30, 2025
  10. fagia commented on Dec 22, 2025

    @fagia
    fagia
    on Dec 22, 2025
    More actions

    Still same issue also with Angular 21.0.1

  11. Ritzlgrmft commented on Jan 12, 2026

    @Ritzlgrmft
    Ritzlgrmft
    on Jan 12, 2026
    More actions

    still the same issue with Angular 21.0.5

    is there any workaround beside ignoring signal lines like:

    // c8 ignore next 
    protected readonly title = signal('my-signal');
    
  12. clydin
    marked Incorrect branch coverage with Vitest on Node 24 (V8 13.6) angular-cli#32283 as a duplicate of this issue on Jan 14, 2026
  13. Martinspire commented on Feb 26, 2026

    @Martinspire
    Martinspire
    on Feb 26, 2026
    More actions

    So what can we do about this? Is there some setting that is conflicting or what? With Analog Vitest, I did not have this issue (perhaps because they compiled it themselves). But migration is blocked if the numbers aren't reported properly. I also think that ignoring code might lead to other issues as well.

  14. mpalourdio commented on Feb 26, 2026

    @mpalourdio
    mpalourdio
    on Feb 26, 2026
    More actions

    I find this a little irritating too. We force quality gates in our CI (based on code coverage among other metrics), but for now, we had to disable this check for angular 21 projects.

    Could this get a bit of love please ? Thanks!

    Reacted by Chris Barr
  15. dgp1130
    added a commit that references this issue on Feb 26, 2026

    fix(compiler-cli): ignore generated ngDevMode signal branch for code …

    This issue will close once commit 2e53627 is merged into the 'main' branch.
    2e53627
  16. atscott
    closed this as completedin #67339on Mar 4, 2026
  17. atscott
    added a commit that references this issue on Mar 4, 2026

    fix(compiler-cli): ignore generated ngDevMode signal branch for code …

    This issue will close once commit 05d022d is merged into the 'main' branch.
    05d022d
  18. angular-robot
    added a commit that references this issue on Mar 4, 2026

    fix(compiler-cli): ignore generated ngDevMode signal branch for code …

    This issue will close once commit dc4cf64 is merged into the 'main' branch.
    dc4cf64
  19. clydin
    marked Vitest: Coverage reporter flagging parenthesis and TS type as uncovered branches angular-cli#32718 as a duplicate of this issue on Mar 9, 2026
  20. anushkasingh-commits
    added a commit that references this issue on Mar 24, 2026

    fix(compiler-cli): ignore generated ngDevMode signal branch for code …

    This issue will close once commit 292f0e9 is merged into the 'main' branch.
    292f0e9
  21. angular-automatic-lock-bot commented on Apr 4, 2026

    @angular-automatic-lock-bot
    angular-automatic-lock-botBot
    on Apr 4, 2026
    More actions

    This issue has been automatically locked due to inactivity.
    Please file a new issue if you are encountering a similar or related problem.

    Read more about our automatic conversation locking policy.

    This action has been performed automatically by a bot.

  22. angular-automatic-lock-bot
    locked and limited conversation to collaborators on Apr 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: compilerIssues related to `ngc`, Angular's template compilerIssues related to `ngc`, Angular's template compilercross-cutting: signals

    Type

    No type

    Projects

    No projects

      Milestone

      • needsTriageNo due date

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.