You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/* node:coverage ignore next */ comments were not properly excluding branches from LCOV coverage output. When a branch was ignored, the LCOV reporter still emitted BRDA entries with count=0, causing BRF (branches
found) to exceed BRH (branches hit) even though the uncovered code was supposed to be ignored.
Root Cause
V8's block coverage ranges for branches can include structural elements like closing braces (}) that belong to the parent scope. The existing check range.ignoredLines === range.lines.length fails in this case
because the closing brace line isn't marked as ignored — it's covered by the parent function range.
For example:
functiongetValue(condition){if(condition){return'truthy';}// ← line covered by parent range, not ignored/* node:coverage ignore next */return'falsy';// ← ignored}
V8's false branch range spans from return 'falsy' to }. Since } isn't ignored, ignoredLines !== lines.length, so the branch wasn't excluded.
Fix
Mark the ignore comment line itself as ignored (coverageLine.ignore = true), so it no longer counts as an uncovered line.
Add a secondary check in summary(): for uncovered branches (count === 0) that contain ignored lines (ignoredLines > 0), skip the branch if all non-ignored lines are already covered (count > 0) by other ranges.
This handles the case where V8's branch range includes structural lines covered by the parent range, but the actual uncovered code is all on ignored lines.
Test Coverage
getValue() — branch where false path is fully ignored → branch excluded from LCOV
getMixed() — branch with both ignored and non-ignored uncovered code → branch correctly kept in LCOV
❌ Patch coverage is 86.36364% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 89.68%. Comparing base (ae228c1) to head (1c9bd19). ⚠️ Report is 25 commits behind head on main.
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
duplicateIssues and PRs that are duplicates of other issues or PRs.needs-ciPRs that need a full CI run.test_runnerIssues and PRs related to the test runner subsystem.
4 participants
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.
Summary
Fixes #61586
/* node:coverage ignore next */ comments were not properly excluding branches from LCOV coverage output. When a branch was ignored, the LCOV reporter still emitted BRDA entries with count=0, causing BRF (branches
found) to exceed BRH (branches hit) even though the uncovered code was supposed to be ignored.
Root Cause
V8's block coverage ranges for branches can include structural elements like closing braces (}) that belong to the parent scope. The existing check range.ignoredLines === range.lines.length fails in this case
because the closing brace line isn't marked as ignored — it's covered by the parent function range.
For example:
V8's false branch range spans from return 'falsy' to }. Since } isn't ignored, ignoredLines !== lines.length, so the branch wasn't excluded.
Fix
This handles the case where V8's branch range includes structural lines covered by the parent range, but the actual uncovered code is all on ignored lines.
Test Coverage