Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

coveradge

brettz9250MIT0.8.2

Generate coverage badges during local nyc/istanbul execution

coverage, nyc, istanbul

readme

npm Dependencies devDependencies

testing badge coverage badge

Known Vulnerabilities Total Alerts Code Quality: Javascript

Licenses badge

(see also licenses for dev. deps.)

issuehunt-to-marktext

coveradge

Installation

If you need png export, run:

npm i -D coveradge convert-svg-to-png

Otherwise, just this:

npm i -D coveradge

Usage

  1. Ensure you have at least the following reporter in your package.json:
{
  "nyc": {
    "reporter": [
      "json-summary"
    ]
  }
}

You may optionally set coverage thresholds and/or watermarks:

{
  "nyc": {
    "reporter": [
      "json-summary"
    ],
    "branches": 80,
    "lines": 80,
    "functions": 80,
    "statements": 80,
    "watermarks": {
      "lines": [80, 95],
      "functions": [80, 95],
      "branches": [80, 95],
      "statements": [80, 95]
    }
  }
}

The watermarks, if present, will be given precedence over the regular thresholds for determining color (though not as high of a precedence as command-line thresholds).

  1. Add --reporter coveradge at the beginning of the nyc call. Alternatively, e.g., if you need to build a coveradge badge after testing has already finished for a merged coverage file, add a call to coveradge in your package.json scripts at some point after running nyc.

  2. Add any desired options. If using as an nyc --reporter, then add the options to package.json instead of a coveradgeOptions property. Otherwise, pass as CLI or programmatic options. (See below for the choices.)

  3. Add the badge to your README (e.g., [![coverage badge](coverage-badge.svg)](coverage-badge.svg)) or for a link that will also work on npmjs.com: [![coverage badge](https://raw.githubusercontent.com/brettz9/coveradge/master/coverage-badge.svg?sanitize=true)](coverage-badge.svg)

That's it!

Options

CLI instructions

See also

  • eslint-formatter-badger - Locally created badges indicating linting results (as run against your project and/or your dependencies)
  • filesize-badger - Locally created badges indicating file size (also buildable as part of Rollup routine)
  • mocha-badge-generator - Locally created badges for Mocha test results
  • license-badger - Locally-created badges indicating license types (by degree of permissiveness) used within or required by the project.

changelog

CHANGES for coveradge

0.8.2

  • fix: switch to rpl/badge-up

0.8.1

User-impacting

  • chore: use fork of badge-up that drops vulernabilities

0.8.0

User-impacting

BREAKING: Requires Node 14+

  • chore: updates command-line-basics

Dev-impacting

  • refactor: Move package to ESM where possible
  • chore: updates devDeps.

0.7.0

User-impacting

  • Breaking change: Require Node 12
  • Docs: Update badges per updated badge devDeps.
  • npm: Update istanbuljs/load-nyc-config

Dev-impacting

  • Linting (ESLint): As per latest ash-nazg
  • Linting (LGTM): Add lgtm.yml
  • npm: Change to maintained mocha-multi-reporters
  • npm: Use prepublishOnly script over prepare
  • npm: Fix reporter path for pnpm
  • npm: Switch to pnpm
  • npm: Update devDeps.

0.6.0

  • Refactoring: Remove unneeded code
  • Linting: As per latest ash-nazg; apply sauron-node rather than sauron
  • npm: Change to stable badge-up version
  • npm: Change to maintained cypress-multi-reporters
  • npm: Add prepare script
  • npm: Ignore mocha files
  • npm: Update devDeps

0.5.0

  • Breaking change: Minimum of Node 10
  • Breaking change: Switch to badge-up so we can use different colors together; drop template argument as a result.
  • Breaking change: Change color to passColor and add failColor
  • Breaking change: Remove pct param within textTemplate in favor of new options (i.e., conditionPct as well as each condition with Pct as suffix, e.g., statementsPct and statementsThreshold).
  • Enhancement: Change color if meeting user-chosen nyc thresholds (e.g., 100%), passing on the calculated condition (the first condition within the optional conditions to fail or not pass medium, or if all are passing, then the first), and the new optional *Threshold params, to textTemplate
  • Enhancement: Allow watermarks from nyc or within threshold CLI options
  • Enhancement: Allow use as a regular nyc custom reporter (--reporter coveradge)
  • Enhancement: Allow reporting (with colors) for each condition or by aggregate
  • Enhancement: Allow intro section
  • Enhancement: Allow programmatic API to access coverageSummary JSON
  • Linting: As per latest ash-nazg
  • Docs: Add badges (license, testing, npm, lgtm)
  • Docs: Add coveradge badge for coveradge itself
  • Maintenance: 4 sp. for MD files
  • Testing: Begin Mocha + nyc tests
  • npm: Update devDeps.

0.4.0

  • npm: Update command-line-basics dep. and devDeps.

0.3.0

  • Docs: Clarify installation
  • npm: Rename script to build-cli-svg
  • npm: Update dep. command-line-basics
  • npm: Update devDeps

0.2.0

  • Linting (ESLint): Latest as per ash-nazg
  • npm: Remove large convert-svg-to-png as a dep.; can still be used but must now be added by user
  • npm: Remove .nyc_output in npm
  • npm: Bump devDeps

0.1.0

  • Initial commit