Skip to content

Commit f79d7af

Browse files
committed
test_runner: exclude ignored branches from BRDA in lcov output
When using node:coverage ignore comments, line coverage (DA entries) is correctly excluded from the lcov output, but branch coverage (BRDA entries) for branches pointing to ignored lines still appears as uncovered. This causes branch coverage percentages to be incorrectly low. Skip branches entirely when all their lines are ignored by coverage comments, consistent with how ignored lines are already excluded from line reports. Fixes: #61586
1 parent 7547e79 commit f79d7af

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

lib/internal/test_runner/coverage.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,14 +193,20 @@ class TestCoverage {
193193
ObjectAssign(range, mapRangeToLines(range, lines));
194194

195195
if (isBlockCoverage) {
196+
// Skip branches where all lines are ignored by coverage
197+
// comments. This is consistent with how ignored lines are
198+
// excluded from line reports (DA entries in lcov).
199+
if (range.ignoredLines === range.lines.length) {
200+
continue;
201+
}
202+
196203
ArrayPrototypePush(branchReports, {
197204
__proto__: null,
198205
line: range.lines[0]?.line,
199206
count: range.count,
200207
});
201208

202-
if (range.count !== 0 ||
203-
range.ignoredLines === range.lines.length) {
209+
if (range.count !== 0) {
204210
branchesCovered++;
205211
}
206212

0 commit comments

Comments
 (0)