istanbul-lib-coverage
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|
Istanbul-lib-coverage is a Node.js package that provides a potent API for inspecting, merging, and summarizing coverage information in JavaScript. It is predominantly used for inspecting test coverage in the software testing field.
To utilize istanbul-lib-coverage, follow these steps:
npm i istanbul-lib-coverage
.require
to import it into your file, as shown below:var libCoverage = require('istanbul-lib-coverage');
var libCoverage = require('istanbul-lib-coverage');
var map = libCoverage.createCoverageMap(globalCoverageVar);
var summary = libCoverage.createCoverageSummary();
// merge another coverage map into the one we created
map.merge(otherCoverageMap);
// inspect and summarize all file coverage objects in the map
map.files().forEach(function(f) {
var fc = map.fileCoverageFor(f),
s = fc.toSummary();
summary.merge(s);
});
console.log('Global summary', summary);
Here, we generate a coverage map using the createCoverageMap
function, from a global coverage variable. Then we create a coverage summary using createCoverageSummary
. The created map gets merged with another one using map.merge
function. We then loop through all file coverage objects in the map, extract summaries, and merge them into the original summary. Finally, we print the global summary to console.
The official istanbul-lib-coverage documentation can be found on the GitHub repository: istanbul-lib-coverage. Here, you can dig deep into the library's functionality, view complete API details, and up-to-date version information.