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 initial code coverage support #46017

Merged
merged 2 commits into from Jan 8, 2023
Merged

Conversation

cjihrig
Copy link
Contributor

@cjihrig cjihrig commented Dec 29, 2022

This commit adds code coverage functionality to the node:test module. When node:test is used in conjunction with the new --test-coverage CLI flag, a coverage report is created when the test runner finishes. The coverage summary is forwarded to any test runner reporters so that the display can be customized as desired. This new functionality is compatible with the existing NODE_V8_COVERAGE environment variable as well.

There are still several limitations, which will be addressed in subsequent pull requests:

  • Coverage is only reported for a single process. It is possible to merge coverage reports together. Once this is done, the --test flag will be supported as well.
  • Source maps are not currently supported.
  • Excluding specific files or directories from the coverage report is not currently supported. Node core modules and node_modules/ are excluded though.

@nodejs-github-bot
Copy link
Collaborator

Review requested:

  • @nodejs/test_runner

@nodejs-github-bot nodejs-github-bot added lib / src Issues and PRs related to general changes in the lib or src directory. needs-ci PRs that need a full CI run. labels Dec 29, 2022
@GeoffreyBooth
Copy link
Member

I’m uncomfortable with all these new APIs being added with neither experimental warnings being printed or experimental flags being required. I don’t think it’s enough that they’re marked as experimental in the docs and that the APIs are “opt in” via their own flags or imports. In general we require experimental features to have an --experimental-<feature-name> flag to be enabled at all, so that users are affirming that they’re using a feature that isn’t subject to semver, and we print a warning in addition in case the flag is masked from the user such as via a package.json script command.

@JakobJingleheimer
Copy link
Contributor

Huzzah! I'm excited for this to be available!

RE Geoffrey's comment: Things have generally seemed a little more fast and loose recently. I agree experimental features should print a related warning and their flag should be prefixed with the experimental.

That said, how experimental is this though and how far is it from "stable"?

@GeoffreyBooth
Copy link
Member

That said, how experimental is this though and how far is it from “stable”?

Arguably the test runner overall might be considered fairly close; it’s used internally by Node, so it’s probably what I would consider “release candidate” per #45900. But while it might be considered stable from a “doesn’t have too many bugs” perspective, I think it’s definitely still experimental in that we might easily ship breaking changes to the test runner as we continue to expand its featureset; so a warning would be good to add. The newer parts of the test runner, like the reporters and the code coverage, feel like what I would consider “beta” and arguably the new flags should be --experimental-test-reporter and --experimental-test-coverage.

@GeoffreyBooth GeoffreyBooth added the tsc-agenda Issues and PRs to discuss during the meetings of the TSC. label Dec 30, 2022
@GeoffreyBooth
Copy link
Member

GeoffreyBooth commented Dec 30, 2022

To be clear @cjihrig and @MoLow I think we should have a discussion with the full TSC about both #45900 and the experimental status of the various test runner features (or the test runner overall). I’m not going to block any test runner-related PRs for that reason because I think the status question should be a group decision rather than me using my block like a veto; though we might want to wait on this PR landing before that discussion happens in case the consensus is that this new flag should be --experimental-test-coverage instead of --test-coverage. cc @nodejs/tsc

doc/api/cli.md Outdated Show resolved Hide resolved
Copy link
Member

@vdeturckheim vdeturckheim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I love it a lot!
I don't have much context on the experimental warning part so please take this review "as is" ^^

doc/api/test.md Show resolved Hide resolved
@cjihrig
Copy link
Contributor Author

cjihrig commented Dec 30, 2022

Regarding a flag and warning - I don't recall anyone asking for a CLI flag when the test runner initially landed, and I think adding one for it now would be counterproductive. A warning was emitted before, and it was removed in ad8442f for the same reasons as the args parser.

That said, how experimental is this though and how far is it from "stable"?

I would like to see the test runner stabilize before Node 20 enters LTS. We have mostly been shipping features, and code coverage is the last big missing feature that I personally care about. I'm sure there will be feature requests and bug fixes in the future, but we've (or at least I have) already been trying to avoid breaking changes. It's also worth noting that test coverage of the test runner itself is already on par with the rest of core, and could be even higher if someone dedicated a few hours to low hanging fruit.

doc/api/cli.md Outdated Show resolved Hide resolved
@MoLow
Copy link
Member

MoLow commented Dec 31, 2022

This implementation does LGTM, but without the support for coverage merging & source maps it does feel pretty experimental (in the sense of what value it adds to the existing NODE_V8_COVERAGE)

@cjihrig
Copy link
Contributor Author

cjihrig commented Dec 31, 2022

without the support for coverage merging & source maps it does feel pretty experimental

These are definitely things that I want/plan to support. However, as a counterpoint, the entire hapi org (which requires very high code coverage) is written in plain JavaScript and currently has no support for getting coverage from child processes. Of course, our CLI runner is based on child processes, so I admit the coverage merging is a bigger deal here. These are also things that are straightforward to incorporate without breaking changes.

@cjihrig cjihrig marked this pull request as draft December 31, 2022 18:57
@benjamingr
Copy link
Member

Wouldn't a good compromise be to enable this behavior when --test is passed alongside NODE_V8_COVERAGE which would accomplish this without any more CLI flags or the experimental status debate (as it'd be using two existing options together)?

@MoLow
Copy link
Member

MoLow commented Jan 1, 2023

Wouldn't a good compromise be to enable this behavior when --test is passed alongside NODE_V8_COVERAGE which would accomplish this without any more CLI flags or the experimental status debate (as it'd be using two existing options together)?

NODE_V8_COVERAGE requires specifying a destination for coverage files, but this implementation supports temporal coverage that is just passed to any reporter you use

@cjihrig
Copy link
Contributor Author

cjihrig commented Jan 4, 2023

@GeoffreyBooth can the tsc-agenda Issues and PRs to discuss during the meetings of the TSC. label be removed? I had stopped development on this work because of it.

@GeoffreyBooth GeoffreyBooth removed the tsc-agenda Issues and PRs to discuss during the meetings of the TSC. label Jan 4, 2023
@cjihrig cjihrig marked this pull request as ready for review January 7, 2023 19:14
@nodejs-github-bot
Copy link
Collaborator

@GeoffreyBooth
Copy link
Member

I think the new flag should be --experimental-test-coverage. There’s a lot left to work out regarding this and I think users should be more obviously aware that they’re using an experimental feature.

@nodejs-github-bot
Copy link
Collaborator

@MoLow
Copy link
Member

MoLow commented Jan 26, 2023

This (and probably most other test runner commits) cannot be backported until #45712 is backported.

see #46360

@cjihrig cjihrig removed backport-requested-v18.x PRs awaiting manual backport to the v18.x-staging branch. backport-requested-v19.x labels Feb 2, 2023
MylesBorins pushed a commit that referenced this pull request Feb 18, 2023
This commit adds code coverage functionality to the node:test
module. When node:test is used in conjunction with the new
--test-coverage CLI flag, a coverage report is created when
the test runner finishes. The coverage summary is forwarded to
any test runner reporters so that the display can be customized
as desired. This new functionality is compatible with the
existing NODE_V8_COVERAGE environment variable as well.

There are still several limitations, which will be addressed in
subsequent pull requests:

- Coverage is only reported for a single process. It is possible
  to merge coverage reports together. Once this is done, the
  --test flag will be supported as well.
- Source maps are not currently supported.
- Excluding specific files or directories from the coverage
  report is not currently supported. Node core modules and
  node_modules/ are excluded though.

PR-URL: #46017
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
MylesBorins pushed a commit that referenced this pull request Feb 18, 2023
Add experimental to the name as requested during review.

PR-URL: #46017
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
MylesBorins added a commit that referenced this pull request Feb 19, 2023
Notable changes:

deps:
  * upgrade npm to 9.5.0 (npm team) #46673
  * add ada as a dependency (Yagiz Nizipli) #46410
doc:
  * add debadree25 to collaborators (Debadree Chatterjee) #46716
  * add deokjinkim to collaborators (Deokjin Kim) #46444
doc,lib,src,test:
  * rename --test-coverage (Colin Ihrig) #46017
lib:
  * (SEMVER-MINOR) add aborted() utility function (Debadree Chatterjee) #46494
src:
  * (SEMVER-MINOR) add initial support for single executable applications (Darshan Sen) #45038
  * (SEMVER-MINOR) allow optional Isolate termination in node::Stop() (Shelley Vohr) #46583
  * (SEMVER-MINOR) allow blobs in addition to `FILE*`s in embedder snapshot API (Anna Henningsen) #46491
  * (SEMVER-MINOR) allow snapshotting from the embedder API (Anna Henningsen) #45888
  * (SEMVER-MINOR) make build_snapshot a per-Isolate option, rather than a global one (Anna Henningsen) #45888
  * (SEMVER-MINOR) add snapshot support for embedder API (Anna Henningsen) #45888
  * (SEMVER-MINOR) allow embedder control of code generation policy (Shelley Vohr) #46368
stream:
  * (SEMVER-MINOR) add abort signal for ReadableStream and WritableStream (Debadree Chatterjee) #46273
test_runner:
  * add initial code coverage support (Colin Ihrig) #46017
url:
  * replace url-parser with ada (Yagiz Nizipli) #46410

PR-URL: TODO
@MylesBorins MylesBorins mentioned this pull request Feb 19, 2023
MylesBorins added a commit that referenced this pull request Feb 20, 2023
Notable changes:

deps:
  * upgrade npm to 9.5.0 (npm team) #46673
  * add ada as a dependency (Yagiz Nizipli) #46410
doc:
  * add debadree25 to collaborators (Debadree Chatterjee) #46716
  * add deokjinkim to collaborators (Deokjin Kim) #46444
doc,lib,src,test:
  * rename --test-coverage (Colin Ihrig) #46017
lib:
  * (SEMVER-MINOR) add aborted() utility function (Debadree Chatterjee) #46494
src:
  * (SEMVER-MINOR) add initial support for single executable applications (Darshan Sen) #45038
  * (SEMVER-MINOR) allow optional Isolate termination in node::Stop() (Shelley Vohr) #46583
  * (SEMVER-MINOR) allow blobs in addition to `FILE*`s in embedder snapshot API (Anna Henningsen) #46491
  * (SEMVER-MINOR) allow snapshotting from the embedder API (Anna Henningsen) #45888
  * (SEMVER-MINOR) make build_snapshot a per-Isolate option, rather than a global one (Anna Henningsen) #45888
  * (SEMVER-MINOR) add snapshot support for embedder API (Anna Henningsen) #45888
  * (SEMVER-MINOR) allow embedder control of code generation policy (Shelley Vohr) #46368
stream:
  * (SEMVER-MINOR) add abort signal for ReadableStream and WritableStream (Debadree Chatterjee) #46273
test_runner:
  * add initial code coverage support (Colin Ihrig) #46017
url:
  * replace url-parser with ada (Yagiz Nizipli) #46410

PR-URL: #46725
MylesBorins added a commit to MylesBorins/node that referenced this pull request Feb 20, 2023
Notable changes:

deps:
  * upgrade npm to 9.5.0 (npm team) nodejs#46673
  * add ada as a dependency (Yagiz Nizipli) nodejs#46410
doc:
  * add debadree25 to collaborators (Debadree Chatterjee) nodejs#46716
  * add deokjinkim to collaborators (Deokjin Kim) nodejs#46444
doc,lib,src,test:
  * rename --test-coverage (Colin Ihrig) nodejs#46017
lib:
  * (SEMVER-MINOR) add aborted() utility function (Debadree Chatterjee) nodejs#46494
src:
  * (SEMVER-MINOR) add initial support for single executable applications (Darshan Sen) nodejs#45038
  * (SEMVER-MINOR) allow optional Isolate termination in node::Stop() (Shelley Vohr) nodejs#46583
  * (SEMVER-MINOR) allow blobs in addition to `FILE*`s in embedder snapshot API (Anna Henningsen) nodejs#46491
  * (SEMVER-MINOR) allow snapshotting from the embedder API (Anna Henningsen) nodejs#45888
  * (SEMVER-MINOR) make build_snapshot a per-Isolate option, rather than a global one (Anna Henningsen) nodejs#45888
  * (SEMVER-MINOR) add snapshot support for embedder API (Anna Henningsen) nodejs#45888
  * (SEMVER-MINOR) allow embedder control of code generation policy (Shelley Vohr) nodejs#46368
stream:
  * (SEMVER-MINOR) add abort signal for ReadableStream and WritableStream (Debadree Chatterjee) nodejs#46273
test_runner:
  * add initial code coverage support (Colin Ihrig) nodejs#46017
url:
  * replace url-parser with ada (Yagiz Nizipli) nodejs#46410

PR-URL: nodejs#46725
MylesBorins added a commit that referenced this pull request Feb 20, 2023
Notable changes:

deps:
  * upgrade npm to 9.5.0 (npm team) #46673
  * add ada as a dependency (Yagiz Nizipli) #46410
doc:
  * add debadree25 to collaborators (Debadree Chatterjee) #46716
  * add deokjinkim to collaborators (Deokjin Kim) #46444
doc,lib,src,test:
  * rename --test-coverage (Colin Ihrig) #46017
lib:
  * (SEMVER-MINOR) add aborted() utility function (Debadree Chatterjee) #46494
src:
  * (SEMVER-MINOR) add initial support for single executable applications (Darshan Sen) #45038
  * (SEMVER-MINOR) allow optional Isolate termination in node::Stop() (Shelley Vohr) #46583
  * (SEMVER-MINOR) allow blobs in addition to `FILE*`s in embedder snapshot API (Anna Henningsen) #46491
  * (SEMVER-MINOR) allow snapshotting from the embedder API (Anna Henningsen) #45888
  * (SEMVER-MINOR) make build_snapshot a per-Isolate option, rather than a global one (Anna Henningsen) #45888
  * (SEMVER-MINOR) add snapshot support for embedder API (Anna Henningsen) #45888
  * (SEMVER-MINOR) allow embedder control of code generation policy (Shelley Vohr) #46368
stream:
  * (SEMVER-MINOR) add abort signal for ReadableStream and WritableStream (Debadree Chatterjee) #46273
test_runner:
  * add initial code coverage support (Colin Ihrig) #46017
url:
  * replace url-parser with ada (Yagiz Nizipli) #46410

PR-URL: #46725
MylesBorins added a commit that referenced this pull request Feb 20, 2023
Notable changes:

deps:
  * upgrade npm to 9.5.0 (npm team) #46673
  * add ada as a dependency (Yagiz Nizipli) #46410
doc:
  * add debadree25 to collaborators (Debadree Chatterjee) #46716
  * add deokjinkim to collaborators (Deokjin Kim) #46444
doc,lib,src,test:
  * rename --test-coverage (Colin Ihrig) #46017
lib:
  * (SEMVER-MINOR) add aborted() utility function (Debadree Chatterjee) #46494
src:
  * (SEMVER-MINOR) add initial support for single executable applications (Darshan Sen) #45038
  * (SEMVER-MINOR) allow optional Isolate termination in node::Stop() (Shelley Vohr) #46583
  * (SEMVER-MINOR) allow blobs in addition to `FILE*`s in embedder snapshot API (Anna Henningsen) #46491
  * (SEMVER-MINOR) allow snapshotting from the embedder API (Anna Henningsen) #45888
  * (SEMVER-MINOR) make build_snapshot a per-Isolate option, rather than a global one (Anna Henningsen) #45888
  * (SEMVER-MINOR) add snapshot support for embedder API (Anna Henningsen) #45888
  * (SEMVER-MINOR) allow embedder control of code generation policy (Shelley Vohr) #46368
stream:
  * (SEMVER-MINOR) add abort signal for ReadableStream and WritableStream (Debadree Chatterjee) #46273
test_runner:
  * add initial code coverage support (Colin Ihrig) #46017
url:
  * replace url-parser with ada (Yagiz Nizipli) #46410

PR-URL: #46725
MylesBorins added a commit that referenced this pull request Feb 20, 2023
Notable changes:

deps:
  * upgrade npm to 9.5.0 (npm team) #46673
  * add ada as a dependency (Yagiz Nizipli) #46410
doc:
  * add debadree25 to collaborators (Debadree Chatterjee) #46716
  * add deokjinkim to collaborators (Deokjin Kim) #46444
doc,lib,src,test:
  * rename --test-coverage (Colin Ihrig) #46017
lib:
  * (SEMVER-MINOR) add aborted() utility function (Debadree Chatterjee) #46494
src:
  * (SEMVER-MINOR) add initial support for single executable applications (Darshan Sen) #45038
  * (SEMVER-MINOR) allow optional Isolate termination in node::Stop() (Shelley Vohr) #46583
  * (SEMVER-MINOR) allow blobs in addition to `FILE*`s in embedder snapshot API (Anna Henningsen) #46491
  * (SEMVER-MINOR) allow snapshotting from the embedder API (Anna Henningsen) #45888
  * (SEMVER-MINOR) make build_snapshot a per-Isolate option, rather than a global one (Anna Henningsen) #45888
  * (SEMVER-MINOR) add snapshot support for embedder API (Anna Henningsen) #45888
  * (SEMVER-MINOR) allow embedder control of code generation policy (Shelley Vohr) #46368
stream:
  * (SEMVER-MINOR) add abort signal for ReadableStream and WritableStream (Debadree Chatterjee) #46273
test_runner:
  * add initial code coverage support (Colin Ihrig) #46017
url:
  * replace url-parser with ada (Yagiz Nizipli) #46410

PR-URL: #46725
MylesBorins added a commit that referenced this pull request Feb 21, 2023
Notable changes:

deps:
  * upgrade npm to 9.5.0 (npm team) #46673
  * add ada as a dependency (Yagiz Nizipli) #46410
doc:
  * add debadree25 to collaborators (Debadree Chatterjee) #46716
  * add deokjinkim to collaborators (Deokjin Kim) #46444
doc,lib,src,test:
  * rename --test-coverage (Colin Ihrig) #46017
lib:
  * (SEMVER-MINOR) add aborted() utility function (Debadree Chatterjee) #46494
src:
  * (SEMVER-MINOR) add initial support for single executable applications (Darshan Sen) #45038
  * (SEMVER-MINOR) allow optional Isolate termination in node::Stop() (Shelley Vohr) #46583
  * (SEMVER-MINOR) allow blobs in addition to `FILE*`s in embedder snapshot API (Anna Henningsen) #46491
  * (SEMVER-MINOR) allow snapshotting from the embedder API (Anna Henningsen) #45888
  * (SEMVER-MINOR) make build_snapshot a per-Isolate option, rather than a global one (Anna Henningsen) #45888
  * (SEMVER-MINOR) add snapshot support for embedder API (Anna Henningsen) #45888
  * (SEMVER-MINOR) allow embedder control of code generation policy (Shelley Vohr) #46368
stream:
  * (SEMVER-MINOR) add abort signal for ReadableStream and WritableStream (Debadree Chatterjee) #46273
test_runner:
  * add initial code coverage support (Colin Ihrig) #46017
url:
  * replace url-parser with ada (Yagiz Nizipli) #46410

PR-URL: #46725
@MoLow

This comment was marked as resolved.

MoLow pushed a commit to MoLow/node that referenced this pull request Feb 25, 2023
This commit adds code coverage functionality to the node:test
module. When node:test is used in conjunction with the new
--test-coverage CLI flag, a coverage report is created when
the test runner finishes. The coverage summary is forwarded to
any test runner reporters so that the display can be customized
as desired. This new functionality is compatible with the
existing NODE_V8_COVERAGE environment variable as well.

There are still several limitations, which will be addressed in
subsequent pull requests:

- Coverage is only reported for a single process. It is possible
  to merge coverage reports together. Once this is done, the
  --test flag will be supported as well.
- Source maps are not currently supported.
- Excluding specific files or directories from the coverage
  report is not currently supported. Node core modules and
  node_modules/ are excluded though.

PR-URL: nodejs#46017
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
MoLow pushed a commit to MoLow/node that referenced this pull request Feb 25, 2023
Add experimental to the name as requested during review.

PR-URL: nodejs#46017
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
@MoLow MoLow added the backport-open-v18.x Indicate that the PR has an open backport. label Feb 25, 2023
MoLow pushed a commit to MoLow/node that referenced this pull request Feb 25, 2023
This commit adds code coverage functionality to the node:test
module. When node:test is used in conjunction with the new
--test-coverage CLI flag, a coverage report is created when
the test runner finishes. The coverage summary is forwarded to
any test runner reporters so that the display can be customized
as desired. This new functionality is compatible with the
existing NODE_V8_COVERAGE environment variable as well.

There are still several limitations, which will be addressed in
subsequent pull requests:

- Coverage is only reported for a single process. It is possible
  to merge coverage reports together. Once this is done, the
  --test flag will be supported as well.
- Source maps are not currently supported.
- Excluding specific files or directories from the coverage
  report is not currently supported. Node core modules and
  node_modules/ are excluded though.

PR-URL: nodejs#46017
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
MoLow pushed a commit to MoLow/node that referenced this pull request Feb 25, 2023
Add experimental to the name as requested during review.

PR-URL: nodejs#46017
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
MoLow pushed a commit to MoLow/node that referenced this pull request Feb 25, 2023
Add experimental to the name as requested during review.

PR-URL: nodejs#46017
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
@MoLow MoLow mentioned this pull request Mar 3, 2023
juanarbol pushed a commit that referenced this pull request Mar 3, 2023
This commit adds code coverage functionality to the node:test
module. When node:test is used in conjunction with the new
--test-coverage CLI flag, a coverage report is created when
the test runner finishes. The coverage summary is forwarded to
any test runner reporters so that the display can be customized
as desired. This new functionality is compatible with the
existing NODE_V8_COVERAGE environment variable as well.

There are still several limitations, which will be addressed in
subsequent pull requests:

- Coverage is only reported for a single process. It is possible
  to merge coverage reports together. Once this is done, the
  --test flag will be supported as well.
- Source maps are not currently supported.
- Excluding specific files or directories from the coverage
  report is not currently supported. Node core modules and
  node_modules/ are excluded though.

PR-URL: #46017
Backport-PR-URL: #46839
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
juanarbol pushed a commit that referenced this pull request Mar 3, 2023
Add experimental to the name as requested during review.

PR-URL: #46017
Backport-PR-URL: #46839
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
juanarbol added a commit that referenced this pull request Mar 3, 2023
Notable Changes:

buffer:
  * (SEMVER-MINOR) add isAscii method (Yagiz Nizipli) #46046
doc,lib,src,test:
  * rename --test-coverage (Colin Ihrig) #46017
fs:
  * (SEMVER-MINOR) add statfs() functions (Colin Ihrig) #46358
src,lib:
  * (SEMVER-MINOR) add constrainedMemory API for process (theanarkh) #46218
test_runner:
  * add initial code coverage support (Colin Ihrig) #46017
  * (SEMVER-MINOR) add reporters (Moshe Atlow) #45712
v8:
  * (SEMVER-MINOR) support gc profile (theanarkh) #46255
vm:
  * (SEMVER-MINOR) expose cachedDataRejected for vm.compileFunction (Anna Henningsen) #46320

PR-URL: #46920
juanarbol pushed a commit that referenced this pull request Mar 5, 2023
This commit adds code coverage functionality to the node:test
module. When node:test is used in conjunction with the new
--test-coverage CLI flag, a coverage report is created when
the test runner finishes. The coverage summary is forwarded to
any test runner reporters so that the display can be customized
as desired. This new functionality is compatible with the
existing NODE_V8_COVERAGE environment variable as well.

There are still several limitations, which will be addressed in
subsequent pull requests:

- Coverage is only reported for a single process. It is possible
  to merge coverage reports together. Once this is done, the
  --test flag will be supported as well.
- Source maps are not currently supported.
- Excluding specific files or directories from the coverage
  report is not currently supported. Node core modules and
  node_modules/ are excluded though.

PR-URL: #46017
Backport-PR-URL: #46839
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
juanarbol pushed a commit that referenced this pull request Mar 5, 2023
Add experimental to the name as requested during review.

PR-URL: #46017
Backport-PR-URL: #46839
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
juanarbol added a commit that referenced this pull request Mar 5, 2023
Notable changes:

buffer:
  * (SEMVER-MINOR) add isAscii method (Yagiz Nizipli) #46046
doc,lib,src,test:
  * rename --test-coverage (Colin Ihrig) #46017
fs:
  * (SEMVER-MINOR) add statfs() functions (Colin Ihrig) #46358
src,lib:
  * (SEMVER-MINOR) add constrainedMemory API for process (theanarkh) #46218
test_runner:
  * add initial code coverage support (Colin Ihrig) #46017
  * (SEMVER-MINOR) add reporters (Moshe Atlow) #45712
v8:
  * (SEMVER-MINOR) support gc profile (theanarkh) #46255
vm:
  * (SEMVER-MINOR) expose cachedDataRejected for vm.compileFunction (Anna Henningsen) #46320

PR-URL: https://github.com/nodejs/node/pull/46920/commits
juanarbol added a commit that referenced this pull request Mar 5, 2023
Notable changes:

buffer:
  * (SEMVER-MINOR) add isAscii method (Yagiz Nizipli) #46046
doc,lib,src,test:
  * rename --test-coverage (Colin Ihrig) #46017
fs:
  * (SEMVER-MINOR) add statfs() functions (Colin Ihrig) #46358
src,lib:
  * (SEMVER-MINOR) add constrainedMemory API for process (theanarkh) #46218
test_runner:
  * add initial code coverage support (Colin Ihrig) #46017
  * (SEMVER-MINOR) add reporters (Moshe Atlow) #45712
v8:
  * (SEMVER-MINOR) support gc profile (theanarkh) #46255
vm:
  * (SEMVER-MINOR) expose cachedDataRejected for vm.compileFunction (Anna Henningsen) #46320

PR-URL: #46920
juanarbol added a commit that referenced this pull request Mar 5, 2023
Notable changes:

buffer:
  * (SEMVER-MINOR) add isAscii method (Yagiz Nizipli) #46046
doc,lib,src,test:
  * rename --test-coverage (Colin Ihrig) #46017
fs:
  * (SEMVER-MINOR) add statfs() functions (Colin Ihrig) #46358
src,lib:
  * (SEMVER-MINOR) add constrainedMemory API for process (theanarkh) #46218
test_runner:
  * add initial code coverage support (Colin Ihrig) #46017
  * (SEMVER-MINOR) add reporters (Moshe Atlow) #45712
v8:
  * (SEMVER-MINOR) support gc profile (theanarkh) #46255
vm:
  * (SEMVER-MINOR) expose cachedDataRejected for vm.compileFunction (Anna Henningsen) #46320

PR-URL: #46920
juanarbol added a commit that referenced this pull request Mar 7, 2023
Notable changes:

buffer:
  * (SEMVER-MINOR) add isAscii method (Yagiz Nizipli) #46046
doc,lib,src,test:
  * rename --test-coverage (Colin Ihrig) #46017
fs:
  * (SEMVER-MINOR) add statfs() functions (Colin Ihrig) #46358
src,lib:
  * (SEMVER-MINOR) add constrainedMemory API for process (theanarkh) #46218
test_runner:
  * add initial code coverage support (Colin Ihrig) #46017
  * (SEMVER-MINOR) add reporters (Moshe Atlow) #45712
v8:
  * (SEMVER-MINOR) support gc profile (theanarkh) #46255
vm:
  * (SEMVER-MINOR) expose cachedDataRejected for vm.compileFunction (Anna Henningsen) #46320

PR-URL: #46920
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-open-v18.x Indicate that the PR has an open backport. lib / src Issues and PRs related to general changes in the lib or src directory. needs-ci PRs that need a full CI run. notable-change PRs with changes that should be highlighted in changelogs. test_runner
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet