Skip to content

[quality] coverage gap: main() in tests/tools/coverage-report.mjs has three unexecuted CLI paths #718

Description

@hivecommons-hive

Finding

tests/tools/coverage-report.mjs is the reporter CI runs for npm run test:unit:coverage and test:unit:coverage:check. Its main() has three paths that no test executes:

lines path
76-78 parseArgs: a bare node --test argument given without a -- separator, which must be passed through rather than read as a flag
570-578 the Not reported (N) notice: the only signal that a file's coverage was recorded against loader-generated text (a JSON module wrapper or transpiled JSX) and is therefore absent from the table
580-583 the non-zero exit taken when the spawned suite itself fails, which must still print the table and must propagate the suite's status ahead of the --check gates

tests/coverage-report.test.mjs already drives the reporter as a subprocess, but its runReporter helper deletes NODE_V8_COVERAGE from the child environment, so nothing the reporter process does is recorded. The --check gates it exercises are pinned by exit code alone; the three paths above carry no exit code of their own to assert on, so they are invisible to the report the tool publishes about itself.

Consequence: a regression in any of the three is silent. A dropped Not reported notice would hide unmapped files entirely; a broken suite-failure exit would let a red suite report green coverage and exit 0.

Evidence

  • Unit: npm run test:unit:coverage at b54cf81 reports tests/tools/coverage-report.mjs | 96.21 | 93.10 | 77-78 409-410 437-438 447-448 470-473 571-578 581-583. Sub-line region offsets were extracted from the same NODE_V8_COVERAGE dump via the tool's own collect() and summarizeRegions().
  • End-to-end: tests/e2e/smoke.spec.js is a Playwright smoke test of the rendered site; it does not execute the repository's own tooling, so it cannot cover this file. No end-to-end evidence exists for it either way.
  • Lines 437-438, 447-448 and 470-473 are inside collect() and are already claimed by open PR test(coverage-report): cover collect()'s merge and record-skip paths #702; they are out of scope here.
  • Lines 409-410 (tryRemapJsx's transpile-failure catch) and the remaining decodeMappings/remapJsxLineCoverage sub-line regions are a separate JSX-remap cluster and are out of scope here.

Recommendation

Add tests/coverage-report-cli.test.mjs with a runReporter helper that keeps NODE_V8_COVERAGE in the child environment (deleting only NODE_TEST_CONTEXT), so the reporter's own execution is recorded. The reporter always overrides NODE_V8_COVERAGE for the node --test run it spawns, so the grandchild still writes to its own directory and the merged counts come only from the reporter. Cover:

  • a bare test path passed without -- reaches node --test and narrows the run to that one suite
  • a suite that imports a JSON module produces the Not reported notice, whose count matches the files it lists
  • a run whose spawned suite fails exits 1, prints Tests failed; coverage above is reported for context., still renders the table, and does not report a --check failure

This lifts the file from 96.21%/93.10% to 98.35%/94.40% (line/region) and all-files line coverage from 99.09% to 99.14%.

Priority

  • Impact: medium
  • Effort: low

Filed by quality agent (hold-gated mode)

🐝 Hive Agent: quality | Instance: hosted-available-lke648397-260827-5n31 | SHA: b54cf81

— hive: agent=quality backend=copilot model=claude-opus-5 copilot=1.0.88

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent/qualityApproved by a Hive merger/owner for auto-merge on green CIhive/hosted-available-lke648397-260827-5n31Approved by a Hive merger/owner for auto-merge on green CIqualityApproved by a Hive merger/owner for auto-merge on green CItestingApproved by a Hive merger/owner for auto-merge on green CI

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions