Skip to content

test_runner: add code coverage support to spec reporter #46665

@richiemccoll

Description

@richiemccoll

What is the problem this feature will solve?

Currently the test runner supports code coverage with the default tap reporter behind the experimental flag.

// node --experimental-test-coverage fixtures.js
running first
TAP version 13
# Subtest: parent block
    # Subtest: child subtest 1 should run
    ok 1 - child subtest 1 should run
      ---
      duration_ms: 1.452902
      ...
    1..1
ok 1 - parent block
  ---
  duration_ms: 6.648896
  ...
1..1
# tests 1
# pass 1
# fail 0
# cancelled 0
# skipped 0
# todo 0
# duration_ms 31.322558
# start of coverage report
# file | line % | branch % | funcs % | uncovered lines
# fixtures.js | 100.00 | 100.00 | 100.00 | 
# all files | 100.00 | 100.00 | 100.00 |
# end of coverage report

When specifying the spec reporter (node --test-reporter=spec --experimental-test-coverage), there is no output.

▶ parent block
  ✔ child subtest 1 should run (1.524443ms)
▶ parent block (5.802161ms)
ℹ tests 1
ℹ pass 1
ℹ fail 0
ℹ cancelled 0
ℹ skipped 0
ℹ todo 0
ℹ duration_ms 28.888102

What is the feature you are proposing to solve the problem?

Add code coverage support by handling the test:coverage event inside the spec reporter.

What alternatives have you considered?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature requestIssues that request new features to be added to Node.js.test_runnerIssues and PRs related to the test runner subsystem.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions