Repository navigation
test_runner: node:coverage ignore comments exclude DA but leave BRDA in lcov output #61586
Copy link
Copy link
Open
Labels
staleIssues and PRs marked stale due to inactivity and scheduled for automatic closure.Issues and PRs marked stale due to inactivity and scheduled for automatic closure.test_runnerIssues and PRs related to the test runner subsystem.Issues and PRs related to the test runner subsystem.
Description
Version
v24.13.0
Platform
Darwin 24.6.0 (macOS)
Subsystem
test_runner
What steps will reproduce the bug?
- Create a file with a branch and
/* node:coverage ignore next */comment:
// src/example.js
function getValue(condition) {
if (condition) {
return 'truthy';
}
/* node:coverage ignore next */
return 'falsy';
}
module.exports = { getValue };- Create a test that only covers the truthy branch:
// test/example.test.js
const { describe, it } = require('node:test');
const assert = require('node:assert');
const { getValue } = require('../src/example.js');
describe('getValue', () => {
it('should return truthy when condition is true', () => {
assert.strictEqual(getValue(true), 'truthy');
});
});- Run with coverage:
node --experimental-test-coverage --test-reporter=lcov --test-reporter-destination=coverage/lcov.info --test test/example.test.js- Examine the generated
lcov.info
How often does it reproduce? Is there a required condition?
Always reproducible.
What is the expected behavior? Why is that the expected behavior?
The /* node:coverage ignore next */ comment should exclude both:
- The DA (line coverage) entry for the ignored line
- The BRDA (branch coverage) entry for the branch leading to the ignored code
This is the expected behavior because:
- The purpose of ignore comments is to exclude code from coverage calculations
c8(which also uses V8 coverage) correctly handles this by marking both DA and BRDA as covered for ignored lines
What do you see instead?
- DA: Line 6 (
return 'falsy';) is correctly excluded from the lcov output - BRDA: Branch entry remains as uncovered:
BRDA:4,2,0,0
BRDA:1,0,0,1
BRDA:1,1,0,1
BRDA:4,2,0,0 <-- This branch should be excluded but remains as uncovered
BRF:3
BRH:2 <-- Only 2 of 3 branches hit (66.67%)
DA:1,1
DA:2,1
DA:3,1
DA:4,1
DA:5,0
DA:7,1 <-- DA:6 is missing (correctly excluded)
...
This causes branch coverage to report 66.67% instead of 100%, which impacts CI/CD pipelines that enforce branch coverage thresholds.
Additional information
Comparison with c8:
Using c8 with /* c8 ignore next */ on the same code structure produces the correct result:
DA:5,1 # Line marked as covered (ignored)
DA:6,1 # Line marked as covered (ignored)
BRDA:5,2,0,1 # Branch marked as covered (ignored)
BRF:3
BRH:3 # All 3 branches "hit" (100%)
Minimal reproduction repository:
https://github.com/tobigumo/node-coverage-brda-bug
git clone https://github.com/tobigumo/node-coverage-brda-bug.git
cd node-coverage-brda-bug
npm install
npm run test
# Compare coverage/lcov-native.info (Node.js native - has bug) with coverage/lcov.info (c8 - correct)Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
staleIssues and PRs marked stale due to inactivity and scheduled for automatic closure.Issues and PRs marked stale due to inactivity and scheduled for automatic closure.test_runnerIssues and PRs related to the test runner subsystem.Issues and PRs related to the test runner subsystem.
Type
Projects
- StatusShow more project fieldsNo status
Activity
spider-yamet commentedon Jan 30, 2026
@tobigumo Hope you are doing great.
I am so interested in this implementation, I just want to know if this issue is open for contributors.
If so, please feel free to assign this task for me.
cc: @benjamingr
Regards
640kmha-lang commentedon Jan 30, 2026
pmarchini commentedon Jan 30, 2026
Hey @spider-yamet, we do not assign tasks, but any contribution is more than welcome 🚀
spider-yamet commentedon Jan 30, 2026
Ok, thanks for your kind response, @pmarchini . then, may I proceed without the assign?
pmarchini commentedon Jan 30, 2026
Sure!
640kmha-lang commentedon Jan 30, 2026
test_runner: exclude ignored lines from BRDA in lcov output
zhanglinqian commentedon Feb 12, 2026
I'd like to work on this issue.
WolffM commentedon Feb 16, 2026
Hello! I'm looking for ways to contribute to to nodejs, can i be assigned to work on this?
test_runner: skip branches entirely on ignored lines
test_runner: exclude ignored branches from BRDA in lcov output
test_runner: fix coverage ignore comments to exclude BRDA entries
Gauravkachwaha commentedon Apr 20, 2026
Hi @tobigumo
I’m interested in working on this issue. Is it open for contributors? If so, I’d be happy to take it up and work on a fix.
cc: @benjamingr
DevRajah commentedon May 6, 2026
Hi, I’d like to work on this if it’s still available.
I’m new to contributing to Node.js, but I’m comfortable with JavaScript/Node.js internals and tests. I’ll keep the PR small and focused on the node:coverage LCOV output behavior described here.
github-actions commentedon Sep 15, 2026
This issue has been marked as stale due to 90 days of inactivity.
It will be automatically closed in 30 days if no further activity occurs. If this is still relevant, please leave a comment or update it to keep it open.