ntcrep
v0.1.0
Published
node:test reporter for generate coverage report
Maintainers
Readme
ntcrep
Node Test Coverage Reporter
node:test reporter for generate coverage reports.
Using code coverage feature on node:test.
Will generate coverage reports in Istanbul format.
Install
npm install ntcrepUsage
For node:test CLI
Please see https://nodejs.org/docs/latest/api/test.html#test-reporters for more information.
// my-test-reporter.js
import { createReporter } from "ntcrep";
export default createReporter({ reporter: "html" });node --test --experimental-test-coverage --test-reporter=./my-test-reporter.jsFor node:test API
Please see https://nodejs.org/docs/latest/api/test.html#runoptions for more information.
import { run } from "node:test";
import { createReporter } from "ntcrep";
run({ coverage: true }).compose(createReporter({ reporter: "html" }));API
createReporter(options?)
Create node:test reporter to generate coverage reports.
Parameters:
[options]{object}: Reporter options.[options.reporter]{string}: Report type to use.[options.reporterOptions]{object}: Options for report type onoptions.reporter[options.outputDirectory]: {string}: Directory to place generated report.
Returns: {import("node:stream").Transform}
Under the hood
This reporter will listen to test:coverage event that available when code coverage is enable.
The event give the simplified (line-based) coverage data that used for generate reports (converted to Istanbul format first). Because the coverage data was simplified, the generation has some limitations:
- The conversion isn't 100% accurate (best-effort).
- When you use the html-based report type, you will see if the partial coverage part is highlighted in one full line. Not in branch tokens.
License
MIT
