Skip to main content
GoodFirstPicks
DashboardIssuesReposLeaderboard

GoodFirstPicks by Leaveitblank © 2026

CreatorRequest a RepoPrivacy PolicyTerms of Service
test_runner: node:coverage ignore comments exclude DA but leave BRDA in lcov output | GoodFirstPicks

test_runner: node:coverage ignore comments exclude DA but leave BRDA in lcov output

nodejs/node 8 comments 1mo ago
View on GitHub
mediumopenScope: somewhat clearSkill match: maybeTest focusedNode.jsJavaScript

Why this is a good first issue

The issue requires understanding of coverage internals and V8 integration.

AI Summary

The issue involves incorrect handling of branch coverage (BRDA) entries when using `node:coverage ignore` comments. The fix requires modifying how coverage data is processed in the test runner to exclude both line and branch coverage for ignored code. The main challenge is understanding the V8 coverage internals and how they integrate with Node.js's test runner.

Issue Description

Version

v24.13.0

Platform

Darwin 24.6.0 (macOS)

Subsystem

test_runner

What steps will reproduce the bug?

  1. 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 };
  1. 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');
  });
});
  1. Run with coverage:
node --experimental-test-coverage --test-reporter=lcov --test-reporter-destination=coverage/lcov.info --test test/example.test.js
  1. 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:

  1. The purpose of ignore comments is to exclude code from coverage calculations
  2. 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

GitHub Labels

good first issuetest_runner

Want to work on this?

Claim this issue to let others know you're working on it. You'll earn 10 points when you complete it!

Risk Flags

  • coverage internals
  • V8 integration
Loading labels...

Details

Points10 pts
Difficultymedium
Scopesomewhat clear
Skill Matchmaybe
Test Focusedyes