Socket
Socket
Sign inDemoInstall

jest-coverage-badges-ts

Package Overview
Dependencies
11
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

jest-coverage-badges-ts


Version published
Weekly downloads
603
decreased by-27.17%
Maintainers
1
Install size
9.45 kB
Created
Weekly downloads
 

Readme

Source

Jest Coverage Badges ts

Create a group of coverage badges for your github repository.

npm

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). Like this:

Coverage lines Coverage functions Coverage branches Coverage statements

This package is a fork of jest-coverage-badges, getting rid of outdated packages and written with typscript.

Usage

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

    Project (in your project folder):

npm install --save jest-coverage-badges-ts yarn add --dev jest-coverage-badges-ts

Global:

npm install --global jest-coverage-badges-ts yarn global add jest-coverage-badges-ts

  1. 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-ts"
    }
    
  2. Run npm test -- --coverage

  3. Run jest-coverage-badges-ts (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.

Example:
$ 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)

© 2021 [Main Author of Adaptations] Christophe Bellec (https://github.com/christophe77)
© 2018 [Main Author of Adaptations] Pamela Peixinho (https://pamepeixinho.github.io)

Keywords

FAQs

Last updated on 01 Aug 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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc