npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@leandroluk/jest-badges

v1.0.2

Published

An evolution of library jest-coverage-badges, adding lots of options and improvements

Downloads

5

Readme

@leandroluk/jest-badges

An evolution of library jest-coverage-badges, adding lots of options and improvements

Create a group of coverage badge

License 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 an extension of jest-coverage-badges, but this one creates all the types of coverage and able to use new variations based on shields.io

Usage

  1. Install @leandroluk/jest-badges in your project or global

    Project (in your project folder):

    npm install --save @leandroluk/jest-badges

    Global:

    npm install --global @leandroluk/jest-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-badges"
    }
  3. Run npm test -- --coverage

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

| Arg | Alias | Default Value | Info | | --- | --- | --- | --- | | --in | -I | <rootDir>/coverage/coverage-summary.json | Refer to coverage-summary.json file, defined as default in jest config file. Example: $ npx jest-badges --in "./cov"| | --out | -O | <rootDir>/coverage | Refer to coverage directory, defined in jest config file. Example $ npx jest-badges --out "./badges" | | --prefix | -P | jest: | Refers to prefix before the badge key value. Example $ npm jest-badges --prefix "example:" | | --style | -S | flat | Refers to available styles in shields.io. Available options:   • flat  • flat-square  • plastic  • social Examples: $ npx jest-badges --style "flat" | | --color-danger | --colorDanger -CD | | Refers to the color when the coverage is in danger. Example $ npm jest-badges --color-danger "pink" | | --color-warn | --colorWarn -CW | | Refers to the color when the coverage is in warning. Example $ npm jest-badges --color-warn "pink" | | --color-ok | --colorOk -CO | | Refers to the color when the coverage are ok. Example $ npm jest-badges --color-ok "pink" | | --threshold-danger | --thresholdDanger -TD | 80 | The value of threshold as danger of coverage. Example $ npm jest-badges --threshold-danger 50 | | --threshold-warn | --thresholdWarn -TW | 90 | The value of threshold as warning of coverage. Example $ npm jest-badges --threshold-warn 50 |

Example:
$ jest-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 (jest-coverage-badges)

© 2023 [Fork and maintainer] Michael Rodov ([email protected])

© 2018 [Main Author of Adaptations] Pamela Peixinho [email protected] (https://pamepeixinho.github.io)