Create a group of coverage badges from jest

Downloads in past


1.1.25 years ago6 years agoMinified + gzip package size for jest-coverage-badges in KB


Jest Coverage Badges
Create a group of coverage badge

!Licenselicense-imagelicense-url npm
Creates a group of code coverage badges like the following:
!Coverage badge greecoverage-badge-green !Coverage badge greecoverage-badge-yellow !Coverage badge greecoverage-badge-red
Currently just reads from Istanbul's JSON summary reporter and downloads a badge from for each jest coverage type (statement, branch, functions, lines). Like this:
Coverage lines Coverage functions Coverage branches Coverage statements
This package is an extension of make-coverage-badge, but this one creates all the types of coverage.


  1. Install jest-coverage-badges in your project or global
*Project* (in your project folder):

```npm install --save jest-coverage-badges```


```npm install --global jest-coverage-badges```
  1. Configure Jest (in package.json):
_(optional: "text" and "lcov")_

    "jest": {
"coverageReporters": [

    If you installed in your project, you can create a script to run it, for example:

    "scripts": {
"test:coverage": "npm test -- --coverage",
"test:badges": "npm run test:coverage  && jest-coverage-badges"
  1. Run npm test -- --coverage

  1. Run jest-coverage-badges (or just run: npm run test:badges)
Resulting in badges:
- `./coverage/badge-statements.svg`
- `./coverage/badge-lines.svg`
- `./coverage/badge-functions.svg`
- `./coverage/badge-branches.svg`

CLI Options

input default: ./coverage/coverage-summary.json - the file (and its path) of the summary json that contains the coverage data
output default: ./coverage - the path to the directory where the svg files will be placed after download. If path doesn't exist it will be created.
``$ jest-coverage-badges input "./cov" output "./badges"``
After this you can add into Github readme (for example) :smiley:

Why use this package?

We have great companies like coveralls and codecov, but it's paid for private repositories. If this package we can add badges in our readme by creating the badges (this can be run at your build, upload to a store and consume in the readme or the website).

Author of adaptation of (make-coverage-badge)

© 2018 Main Author of Adaptations Pamela Peixinho (