Socket
Socket
Sign inDemoInstall

istanbul-lib-coverage

Package Overview
Dependencies
0
Maintainers
4
Versions
29
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

istanbul-lib-coverage

Data library for istanbul coverage objects


Version published
Maintainers
4
Weekly downloads
30,056,105
increased by3.95%
Bundle size
2.3 kB
Minified + gzipped

Weekly downloads

Package description

What is istanbul-lib-coverage?

The istanbul-lib-coverage package is a library for JavaScript test coverage measurement and reporting. It provides a set of APIs to instrument code, collect and aggregate coverage data, and generate reports in various formats. It's part of the Istanbul project, which is widely used for tracking code coverage in JavaScript applications.

What are istanbul-lib-coverage's main functionalities?

Creating a Coverage Map

This feature allows you to create a new coverage map. A coverage map is a data structure that holds coverage data for a set of files. This is the first step in collecting and storing coverage information.

const libCoverage = require('istanbul-lib-coverage');
const map = libCoverage.createCoverageMap();

Adding File Coverage

After creating a coverage map, you can add coverage data for individual files. This involves creating a file coverage object for each file and adding it to the coverage map. This is how you populate the coverage map with data.

const fileCoverage = libCoverage.createFileCoverage('path/to/file.js');
map.addFileCoverage(fileCoverage);

Generating Summary Reports

Once you have a populated coverage map, you can generate summary reports. These summaries provide an overview of the coverage data, including statistics like lines covered, statements covered, and so forth. This is useful for getting a quick insight into the coverage of your project.

const summary = map.getCoverageSummary();
console.log(summary.toJSON());

Other packages similar to istanbul-lib-coverage

Readme

Source

istanbul-lib-coverage

Greenkeeper badge Build Status

An API that provides a read-only view of coverage information with the ability to merge and summarize coverage info.

Supersedes object-utils and collector from the v0 istanbul API.

See the docs for the full API.

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);

Keywords

FAQs

Last updated on 08 Nov 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc