Skip to content

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

Merged
atscott merged 1 commit intoangular:mainfrom
dgp1130:signal-dev-coverage
Mar 4, 2026
Merged

fix(compiler-cli): ignore generated ngDevMode signal branch for code coverage#67339
atscott merged 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
@alan-agius4
Copy link
Contributor

alan-agius4 commented Feb 27, 2026

For vitest this is indeed enough as @vitest/coverage-v8 handles this.

@dgp1130 dgp1130 added action: merge The PR is ready for merge by the caretaker and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels Mar 4, 2026
@dgp1130 dgp1130 removed the request for review from alan-agius4 March 4, 2026 21:08
@atscott atscott merged commit dc4cf64 into angular:main Mar 4, 2026
26 checks passed
@atscott
Copy link
Contributor

atscott commented Mar 4, 2026

This PR was merged into the repository. The changes were merged into the following branches:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

action: merge The PR is ready for merge by the caretaker 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

4 participants