Skip to content

Commit 487ce88

Browse files
author
OpenClaw Agent
committed
test_runner: exclude BRDA entries for ignored lines in lcov output
When a line is marked with node:coverage ignore next, both the DA (line coverage) entry and the BRDA (branch coverage) entry for branches leading to that line should be excluded from the lcov output. This matches the behavior of c8 and ensures that branch coverage percentages are not artificially reduced by ignored code. Fixes: #61586
1 parent 1ea93c7 commit 487ce88

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

lib/internal/test_runner/coverage.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -193,11 +193,16 @@ class TestCoverage {
193193
ObjectAssign(range, mapRangeToLines(range, lines));
194194

195195
if (isBlockCoverage) {
196-
ArrayPrototypePush(branchReports, {
197-
__proto__: null,
198-
line: range.lines[0]?.line,
199-
count: range.count,
200-
});
196+
// If all lines in the branch are ignored, do not include this
197+
// branch in the coverage report (similar to how ignored lines
198+
// are excluded from DA entries in lcov output).
199+
if (range.ignoredLines !== range.lines.length) {
200+
ArrayPrototypePush(branchReports, {
201+
__proto__: null,
202+
line: range.lines[0]?.line,
203+
count: range.count,
204+
});
205+
}
201206

202207
if (range.count !== 0 ||
203208
range.ignoredLines === range.lines.length) {

0 commit comments

Comments
 (0)