Skip to content

test_runner: fix branch count when ignore comment present#63445

Open
MD-Mushfiqur123 wants to merge 2 commits into
nodejs:mainfrom
MD-Mushfiqur123:fix/coverage-ignore-brda
Open

test_runner: fix branch count when ignore comment present#63445
MD-Mushfiqur123 wants to merge 2 commits into
nodejs:mainfrom
MD-Mushfiqur123:fix/coverage-ignore-brda

Conversation

@MD-Mushfiqur123
Copy link
Copy Markdown

Fixes: #61586

When /* node:coverage ignore next */\ is used on a line within a branch (e.g., a
eturn\ after an \if), the DA line entry is correctly excluded from the coverage output. However, the BRDA branch entry still showed \count=0\ for the branch leading to the ignored code.

The existing condition
ange.ignoredLines === range.lines.length\ only caught the case where ALL lines in a V8 range are ignored. But V8 branch ranges often include non-executable lines (like closing braces and comment lines) alongside the ignored executable line, so the strict equality check missed many cases.

Changes in \lib/internal/test_runner/coverage.js:

  • When
    ange.count === 0\ and
    ange.ignoredLines > 0, set the branch count to 1 (covered) in the branch report
  • Broadened the \�ranchesCovered\ condition from
    ange.ignoredLines === range.lines.length\ to
    ange.ignoredLines > 0\

This matches c8's behavior, which marks both DA and BRDA as covered for ignored lines.

@nodejs-github-bot
Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/test_runner

@nodejs-github-bot nodejs-github-bot added needs-ci PRs that need a full CI run. test_runner Issues and PRs related to the test runner subsystem. labels May 20, 2026
@atlowChemi
Copy link
Copy Markdown
Member

@MD-Mushfiqur123 there seem to be multiple other PRs open fixing this bug, this seems like a duplicate?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-ci PRs that need a full CI run. test_runner Issues and PRs related to the test runner subsystem.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

3 participants