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

[node:test] help using node api for node:test's run method with coverage report #4462

Closed
2 tasks done
danehansen opened this issue Aug 5, 2024 · 2 comments
Closed
2 tasks done

Comments

@danehansen
Copy link

Node.js Version

v22.2.0

NPM Version

v10.7.0

Operating System

macOS 14.5

Subsystem

Other

Description

im looking for more help in using the run method from node:test than what the online documentation shows. for example, how can i enable coverage reporting? what would be the way to do the equivalent of --experimental-test-coverage when using the run method? thanks.

Minimal Reproduction

import _process from "node:process";
import { run } from "node:test";
import { tap } from "node:test/reporters";

import { glob } from "glob";

async function testSrc(watch: boolean): Promise {
const files = await glob(
["/*.test.ts", "/.test.tsx", "**/.test.js", "/*.test.jsx"],
{ ignore: ["node_modules/
", "build/**"] },
);

await run({
files,
watch,
})
.on("test:coverage", (data:any) => {
// this never fires
console.log("test:coverage", { data });
})
.compose(tap)
.pipe(_process.stdout);
}

export default testSrc;

Output

No response

Before You Submit

  • I have looked for issues that already exist before submitting this
  • My issue follows the guidelines in the README file, and follows the 'How to ask a good question' guide at https://stackoverflow.com/help/how-to-ask
@RedYetiDev
Copy link
Member

Coverage is currently not supported via the run API, but it's planned for the future.

nodejs/node#53924 has it listed in a roadmap, but if you'd like, you can open a feature request for it in the nodejs/node repository.

@RedYetiDev
Copy link
Member

(Will be) fixed by #53937

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants