fix(compiler-cli): ignore generated ngDevMode signal branch for code coverage#67339
Open
dgp1130 wants to merge 1 commit intoangular:mainfrom
Open
fix(compiler-cli): ignore generated ngDevMode signal branch for code coverage#67339dgp1130 wants to merge 1 commit intoangular:mainfrom
dgp1130 wants to merge 1 commit intoangular:mainfrom
Conversation
…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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The Angular compiler unconditionally adds a debug name transform for signals which generates a conditional on
ngDevMode(e.g.,ngDevMode ? { debugName: "xyz" } : []). During testing,ngDevModeis 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-v8now natively respects the fallback istanbul comment.In conversation with Gemini, I believe
instanbul ignore nextshould 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 separatec8 ignore nextdirective.Fixes #64583
/cc @hawkgs @AleksanderBodurri