Skip to content

Inconsistent BRDA Block Numbers in LCOV Reports When Merging Unit & Functional Test Coverage #1596

@priyankagolla1836

Description

@priyankagolla1836

Issue:

I'm encountering a coverage inconsistency issue when merging nyc coverage from unit and functional test runs in a JavaScript project.

Details:

  • I use nyc to generate coverage reports separately for unit tests and functional tests.
  • Then I merge the .json reports using nyc merge and generate a combined lcov.info using nyc report.
  • When inspecting the merged LCOV file, I notice that for the same line (e.g., line 108), different test runs generate different BRDA block IDs:

Example:

  • Unit Test Coverage:

    BRDA:108,11,0,17
    BRDA:108,11,1,18
    BRDA:108,12,0,35
    
  • Functional Test Coverage:

    BRDA:108,14,0,0
    BRDA:108,14,1,0
    BRDA:108,15,0,0
    

This causes tools like SonarQube to treat the coverage as partial, even though unit tests already fully cover the branches. It appears the block numbers assigned to the same line change across different test runs when not all branches are executed.

Suspected Cause:

nyc may be regenerating block/branch IDs independently for each run, and the merge process doesn't reconcile them into a consistent structure for accurate reporting.

Ask:

  • Is there a way to preserve or align BRDA block IDs across test suites?
  • Can nyc support a consistent branch mapping across multiple runs?
  • Any recommended approach to avoid incorrect partial coverage due to block mismatch?

Environment:

  • nyc version: [fill in]
  • Node.js version: [fill in]
  • OS: [fill in]
  • Test Framework: Jest

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions