Skip to content

timkun/jest-coverage-badges

 
 

Repository files navigation

Jest Coverage Badges

Create a group of coverage badge

License

Creates a group of code coverage badges like the following:

Coverage badge gree Coverage badge gree Coverage badge gree

Currently just reads from Istanbul's JSON summary reporter and downloads a badge from https://shields.io/ for each jest coverage type (statement, branch, functions, lines).

This package is an extension of make-coverage-badge, but this one creates all the types of coverage.

Usage

  1. Install jest-coverage-badges in your project or global

    Project (in your project folder):

    npm install --save jest-coverage-badges

    Global:

    npm install --global jest-coverage-badges

  2. Configure Jest (in package.json):

    (optional: "text" and "lcov")

    "jest": {
      "coverageReporters": [
        "json-summary", 
        "text",
        "lcov"
      ]
    }

    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"
    }
  3. Run npm test -- --coverage

  4. 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

After this you can add into Github readme (for example) 😃

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 [email protected] (https://pamepeixinho.github.io)

About

Create jest coverage badges (from all jest types)

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 92.8%
  • Vim Script 7.2%