v24.13.0
Darwin 24.6.0 (macOS)
test_runner
/* node:coverage ignore next */ comment:// src/example.js
function getValue(condition) {
if (condition) {
return 'truthy';
}
/* node:coverage ignore next */
return 'falsy';
}
module.exports = { getValue };
// 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');
});
});
node --experimental-test-coverage --test-reporter=lcov --test-reporter-destination=coverage/lcov.info --test test/example.test.js
lcov.infoAlways reproducible.
The /* node:coverage ignore next */ comment should exclude both:
This is the expected behavior because:
c8 (which also uses V8 coverage) correctly handles this by marking both DA and BRDA as covered for ignored linesreturn 'falsy';) is correctly excluded from the lcov outputBRDA:4,2,0,0BRDA: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.
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)