You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

coverage-diff

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

coverage-diff

Reports differences between two istanbul JSON code coverage summaries.

3.2.0
latest
Source
npm
Version published
Weekly downloads
15K
-9.54%
Maintainers
1
Weekly downloads
 
Created
Source

coverage-diff

What it does

  • Accepts base-summary.json and head-summary.json
  • Diffs the two jsons and outputs info about
    • Percentage of changed coverage (in changed/added files)
    • Formatted as markdown table
  • Fail if coverage decreases on a file (check on percentage) for any of the lines/func/statements/branches. Can  be configured to only check some criteria.
  • Separate threshold for new files newFileCoverageThreshold, defaults to coverageThreshold if not passed
  • Written in Typescript.

Usage

import fs from 'fs';
import { diff as coverageDiff } from 'coverage-diff';

const base = JSON.parse(fs.readFileSync('./base-summary.json'));
const head = JSON.parse(fs.readFileSync('./head-summary.json'));
const diff = coverageDiff.diff(base, head);

console.log(diff.diff);
console.log(diff.results);
console.log(diff.regression);

Out:

OkFileLinesBranchesFunctionsStatements
🔴file180%
(+10%)
14%
(-30%)
3%
(+20%)
20%
(-10%)
file220%
(+10%)
8%
(-30%)
2%
(-20%)
5%
(-10%)

API at https://flaviusone.github.io/coverage-diff/

FAQs

Package last updated on 23 May 2023

Did you know?

Socket

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