Socket
Socket
Sign inDemoInstall

istanbul-lib-report

Package Overview
Dependencies
5
Maintainers
3
Versions
25
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    istanbul-lib-report

Base reporting library for istanbul


Version published
Weekly downloads
26M
increased by1.71%
Maintainers
3
Install size
154 kB
Created
Weekly downloads
 

Package description

What is istanbul-lib-report?

The istanbul-lib-report package is a library for generating code coverage reports in various formats. It is part of the Istanbul code coverage tooling ecosystem and provides a way to create detailed and summary coverage reports based on the coverage data collected during test execution. This package is typically used in conjunction with other Istanbul libraries to collect and process coverage information.

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

Creating a coverage report

This code demonstrates how to generate an HTML coverage report using istanbul-lib-report. It involves creating a report context with the output directory and coverage map, then executing the report generation with the desired format ('html' in this case).

const libReport = require('istanbul-lib-report');
const reports = require('istanbul-reports');

let context = libReport.createContext({
  dir: './coverage', // Output directory
  watermarks: libReport.getDefaultWatermarks(),
  coverageMap: coverageMap // Assume coverageMap is previously defined
});

let report = reports.create('html', {
  projectRoot: './'
});

report.execute(context);

Configuring watermarks for coverage thresholds

This example shows how to configure watermarks for coverage thresholds in a report. Watermarks define the color coding of coverage results (e.g., red for low coverage, yellow for medium, green for high). The thresholds are set for statements, functions, branches, and lines.

const libReport = require('istanbul-lib-report');

let context = libReport.createContext({
  dir: './coverage',
  watermarks: {
    statements: [50, 80],
    functions: [50, 80],
    branches: [50, 80],
    lines: [50, 80]
  },
  coverageMap: coverageMap
});

Other packages similar to istanbul-lib-report

Readme

Source

istanbul-lib-report

Greenkeeper badge Build Status

Core reporting utilities for istanbul.

Example usage

const libReport = require('istanbul-lib-report');
const reports = require('istanbul-reports');

// coverageMap, for instance, obtained from istanbul-lib-coverage
const coverageMap;

const configWatermarks = {
  statements: [50, 80],
  functions: [50, 80],
  branches: [50, 80],
  lines: [50, 80]
};

// create a context for report generation
const context = libReport.createContext({
  dir: 'report/output/dir',
  // The summarizer to default to (may be overridden by some reports)
  // values can be nested/flat/pkg. Defaults to 'pkg'
  defaultSummarizer: 'nested',
  watermarks: configWatermarks,
  coverageMap,
})

// create an instance of the relevant report class, passing the
// report name e.g. json/html/html-spa/text
const report = reports.create('json', {
  skipEmpty: configSkipEmpty,
  skipFull: configSkipFull
})

// call execute to synchronously create and write the report to disk
report.execute(context)

Keywords

FAQs

Last updated on 20 Dec 2019

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