Skip to content

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

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

atscott merged 1 commit into
angular:mainfrom
dgp1130:signal-dev-coverage

Conversation

@dgp1130

@dgp1130 dgp1130 commented Feb 26, 2026

Copy link
Copy Markdown
Contributor

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

alan-agius4 commented Feb 27, 2026 •

Copy link
Copy Markdown
Contributor

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

atscott commented Mar 4, 2026

Copy link
Copy Markdown
Contributor

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

@angular-automatic-lock-bot

Copy link
Copy Markdown

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.

@angular-automatic-lock-bot angular-automatic-lock-bot Bot locked and limited conversation to collaborators Apr 10, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

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