From 6048b00310bc31064e95f7e0b5dc5e6047124200 Mon Sep 17 00:00:00 2001 From: jorge guerrero Date: Sun, 22 Feb 2026 09:25:16 -0500 Subject: [PATCH] test_runner: fix lcov BRDA output for ignored branches Fix BRDA entries appearing in lcov output for branches on lines excluded by /* node:coverage ignore next */ comments. Branches with all ignored lines are now excluded from branchReports (matching DA line exclusion behavior). Ignored branches still count toward coverage statistics but don't appear in detailed reports. Fixes: https://github.com/nodejs/node/issues/61586 Signed-off-by: jorge guerrero --- lib/internal/test_runner/coverage.js | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/lib/internal/test_runner/coverage.js b/lib/internal/test_runner/coverage.js index 8fa9c872568d1e..326b1ef26f1efd 100644 --- a/lib/internal/test_runner/coverage.js +++ b/lib/internal/test_runner/coverage.js @@ -193,18 +193,24 @@ class TestCoverage { ObjectAssign(range, mapRangeToLines(range, lines)); if (isBlockCoverage) { - ArrayPrototypePush(branchReports, { - __proto__: null, - line: range.lines[0]?.line, - count: range.count, - }); - - if (range.count !== 0 || - range.ignoredLines === range.lines.length) { + // Only add branch to reports if not all lines are ignored + if (range.ignoredLines !== range.lines.length) { + ArrayPrototypePush(branchReports, { + __proto__: null, + line: range.lines[0]?.line, + count: range.count, + }); + + if (range.count !== 0) { + branchesCovered++; + } + + totalBranches++; + } else { + // All lines are ignored - count as covered but don't report branchesCovered++; + totalBranches++; } - - totalBranches++; } }