Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test_runner: add code coverage support to spec reporter #46665

Closed
richiemccoll opened this issue Feb 15, 2023 · 3 comments · Fixed by #46674
Closed

test_runner: add code coverage support to spec reporter #46665

richiemccoll opened this issue Feb 15, 2023 · 3 comments · Fixed by #46674
Labels
feature request Issues that request new features to be added to Node.js. test_runner

Comments

@richiemccoll
Copy link
Contributor

richiemccoll commented Feb 15, 2023

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

@piranna
Copy link
Contributor

piranna commented Mar 10, 2023

As said at #47032, since spec reporter is intended to provide an user readable output, I propose to use Istambul text reporter, that's the same being used by Jest, NYC, and by extension also c8.

@pulkit-30
Copy link
Contributor

As said at #47032, since spec reporter is intended to provide an user readable output, I propose to use Istambul text reporter, that's the same being used by Jest, NYC, and by extension also c8.

Hey @piranna
Thanks for the suggestions, I will update my pr asap 🚀

@piranna
Copy link
Contributor

piranna commented Mar 10, 2023

Thanks for the suggestions, I will update my pr asap

You are welcome :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request Issues that request new features to be added to Node.js. test_runner
Projects
Status: Pending Triage
Development

Successfully merging a pull request may close this issue.

4 participants