Skip to content

fix(compiler-cli): ignore generated ngDevMode signal branch for code coverage#67339

Open
dgp1130 wants to merge 1 commit intoangular:mainfrom
dgp1130:signal-dev-coverage
Open

fix(compiler-cli): ignore generated ngDevMode signal branch for code coverage#67339
dgp1130 wants to merge 1 commit intoangular:mainfrom
dgp1130:signal-dev-coverage

Conversation

@dgp1130
Copy link
Contributor

@dgp1130 dgp1130 commented Feb 26, 2026

The Angular compiler unconditionally adds a debug name transform for signals which generates a conditional on ngDevMode (e.g., ngDevMode ? { debugName: "xyz" } : []). During testing, ngDevMode is true, so the true branch executes but the false branch is never executed. Consequently, coverage tools report the false branch as an untested line/branch, preventing 100% test coverage.

This commit adds a synthetic /* istanbul ignore next */ comment to the generated false branch so that Istanbul ignores it. We only include the istanbul comment (instead of additionally including c8) to focus on the established standard for Angular CLI/Karma coverage while maintaining compatibility with modern Vitest setups, since @vitest/coverage-v8 now natively respects the fallback istanbul comment.

In conversation with Gemini, I believe instanbul ignore next should be sufficient for Karma and Vitest with Istanbul or v8 code coverage, but I'm hoping either @alan-agius4 or @clydin can confirm whether or our code coverage story would benefit from a separate c8 ignore next directive.

Fixes #64583

/cc @hawkgs @AleksanderBodurri

…coverage

The Angular compiler unconditionally adds a debug name transform for signals
which generates a conditional on `ngDevMode` (e.g., `ngDevMode ? { debugName: "xyz" } : []`).
During testing, `ngDevMode` is true, so the true branch executes but the
false branch is never executed. Consequently, coverage tools report the
false branch as an untested line/branch, preventing 100% test coverage.

This commit adds a synthetic `/* istanbul ignore next */` comment to the
generated false branch so that Istanbul ignores it. We only include the
istanbul comment (instead of additionally including c8) to focus on the
established standard for Angular CLI/Karma coverage while maintaining
compatibility with modern Vitest setups, since @vitest/coverage-v8 now
natively respects the fallback istanbul comment.

Fixes angular#64583
@dgp1130 dgp1130 requested a review from alan-agius4 February 26, 2026 21:27
@dgp1130 dgp1130 added action: review The PR is still awaiting reviews from at least one requested reviewer target: patch This PR is targeted for the next patch release area: compiler Issues related to `ngc`, Angular's template compiler labels Feb 26, 2026
@ngbot ngbot bot modified the milestone: Backlog Feb 26, 2026
@pullapprove pullapprove bot requested a review from JoostK February 26, 2026 21:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

action: review The PR is still awaiting reviews from at least one requested reviewer area: compiler Issues related to `ngc`, Angular's template compiler target: patch This PR is targeted for the next patch release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Inaccurate code coverage with aot testing

1 participant