All Projects → olavoparno → istanbul-badges-readme

olavoparno / istanbul-badges-readme

Licence: MIT license
Creates and updates README testing coverage badges with your json-summary

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language
shell
77523 projects

Projects that are alternatives of or similar to istanbul-badges-readme

jest-badges-readme
Creates a group of coverage badges from Jest into your README
Stars: ✭ 30 (-61.04%)
Mutual labels:  readme, coverage, istanbul, jest-badges-readme
ts-node-starter
GitHub template to get started with Node.js & TypeScript. ⚡
Stars: ✭ 28 (-63.64%)
Mutual labels:  nyc, coverage
rollup-plugin-istanbul
Seamless integration between Rollup and Istanbul
Stars: ✭ 39 (-49.35%)
Mutual labels:  coverage, istanbul
jest-puppeteer-istanbul
Collect code coverage information from end-to-end jest puppeteer tests
Stars: ✭ 26 (-66.23%)
Mutual labels:  coverage, istanbul
cov
An emacs extension for displaying coverage data on your code
Stars: ✭ 65 (-15.58%)
Mutual labels:  coverage, lcov
husky
No description or website provided.
Stars: ✭ 50 (-35.06%)
Mutual labels:  husky, githooks
unitest
🌎 Seamless node and browser unit testing with code coverage
Stars: ✭ 28 (-63.64%)
Mutual labels:  coverage, istanbul
currency-api
A demo project on how to test a node/express app with Mocha, Nock and proxyquire (MNP) and code coverage with nyc/istanbul.
Stars: ✭ 19 (-75.32%)
Mutual labels:  nyc, istanbul
playwright-test
Run unit tests with several runners or benchmark inside real browsers with playwright.
Stars: ✭ 81 (+5.19%)
Mutual labels:  nyc, istanbul
tenants
JustFix.nyc is a tool to document, organize, and take action in getting repairs made on your apartment.
Stars: ✭ 15 (-80.52%)
Mutual labels:  nyc
covdefaults
A coverage plugin to provide sensible default settings
Stars: ✭ 38 (-50.65%)
Mutual labels:  coverage
GOVINDDIXIT
GitHub Readme template to create your awesome introduction Readme on GitHub 🚀
Stars: ✭ 18 (-76.62%)
Mutual labels:  readme
laravel-survey
Laravel 6 survey app.
Stars: ✭ 39 (-49.35%)
Mutual labels:  coverage
angular-cli-skeleton
angular-cli skeleton to quickly start a new project with advanced features and best practices. All features are described in README.md.
Stars: ✭ 32 (-58.44%)
Mutual labels:  coverage
CPP Template
C++ project template : CMake, Test, Travis CI, Appveyor, CodeCoverage, Doxygen
Stars: ✭ 32 (-58.44%)
Mutual labels:  coverage
readmeio-sync
↕️ A tool for syncing local markdown files to Readme.io
Stars: ✭ 18 (-76.62%)
Mutual labels:  readme
ui-names
A collection of good (and bad) ui names.
Stars: ✭ 12 (-84.42%)
Mutual labels:  readme
Thomas-George-T
Readme for Github Profile. Don't just fork it, Star it too ⭐!
Stars: ✭ 31 (-59.74%)
Mutual labels:  readme
tutorials as code
so that stuff read/seen don't get muddled up with time
Stars: ✭ 42 (-45.45%)
Mutual labels:  readme
ayushi7rawat
Ayushi Rawat's README
Stars: ✭ 49 (-36.36%)
Mutual labels:  readme

traffic

Istanbul Badges Readme

Creates README badges from istanbul coverage report

Statements Branches Functions Lines
Statements Branches Functions Lines

Table of Contents

Running example

Example


Requirements

  • First, of course, you must have a test runner such as Jest and Mocha;
  • You must have json-summary as a coverageReporter in your tests configuration;
  • For example, if you are using Jest, configuration should either be within package.json or inside your jest config file i.e. jest.config.js or jestconfig.json as written below:
  "coverageReporters": ["json-summary"]

Installation

  • Install the library in your project as a devDependency:
  npm i -D istanbul-badges-readme
  • Add at least one of the below coverage hashes in your README file:

    • ![Statements](#statements#)
    • ![Branches](#branches#)
    • ![Functions](#functions#)
    • ![Lines](#lines#)
  • A simple example of all hashes being used in a table fashion markup:

| Statements                  | Branches                | Functions                 | Lines             |
| --------------------------- | ----------------------- | ------------------------- | ----------------- |
| ![Statements](#statements#) | ![Branches](#branches#) | ![Functions](#functions#) | ![Lines](#lines#) |

Simple Usage

  • Simply run it from the CLI as follows:
  npm run istanbul-badges-readme
  • Or add it to your package.json scripts as follows:
"scripts": {
  "make-badges": "istanbul-badges-readme",
}

Advanced Usage

  • Custom coverage directory? Use --coverageDir argument:
  npm run istanbul-badges-readme --coverageDir="./my-custom-coverage-directory"
  • Custom readme directory? Use --readmeDir argument:
  npm run istanbul-badges-readme --readmeDir="./my-custom-readme-directory"
  • Want it without logging? Try silent mode with --silent argument:
  npm run istanbul-badges-readme --silent
  • You may also create custom labeling for the badges using the corresponding hash and Label e.g. branchesLabel --branchesLabel='Branches are troublesome!':
  npm run istanbul-badges-readme --functionsLabel='Mis funciones!' --branchesLabel='Branches are troublesome!'
  • You can also change the badge styling, according to shields.io's own style reference. See more examples here.
  npm run istanbul-badges-readme --style="for-the-badges"
  • There is an option to use a logo within the badge, as described on shields.io's own documentation which uses all icons available at simple-icons.
  npm run istanbul-badges-readme --logo="jest"
  • To exit with 1 code on validation errors (eg.: README doesn't exist, or coverage directory doesn't exist) or on editing errors (eg.: cannot write to README due to lack of permissions). The default exit code is 0. Set a different one by using --exitCode argument.
  npm run istanbul-badges-readme --exitCode=1

Usage as a part of your githooks

  • If you want to have this run on the pre-commit hook and update the commit in place, just install husky and add the pre-commit script to your package.json.
  1. Install Husky.
  npm install -D husky
  1. Add your pre-commit script:
  "husky": {
    "hooks": {
      "pre-commit": "npm run test && istanbul-badges-readme && git add 'README.md'"
    }
  }
  1. Git Commit and Push. Just use your workflow as usual. If your tests fail, no commit. If they pass, update the README.md and add the file to the commit. Nice!

Usage as a part of your CI

You may want to have peace of mind that contributors have run istanbul-badges-readme locally by performing a simple check in your CI.

The --ci argument will throw an error if the badges generated do not match what is already in the README.md.

You can add this to your package.json as follows:

"scripts": {
  "make-badges": "istanbul-badges-readme",
  "make-badges:ci": "npm run make-badges -- --ci",
}

Where the script make-badges:ci will run your existing make-badges script by just adding --ci as an argument.

This is a useful addition/alternative to the githooks approach for some use cases such as larger codebases, slow computers etc, where it isn't always feasible to run all the tests and produce coverage on each commit.

Custom Badge Styles

  • DEFAULT STYLE Square style='square': Statements

  • Square flat style='square-flat': Statements

  • Plastic style='plastic': Statements

  • For the badge style='for-the-badge': Statements

See running examples

Examples folder

✔️ Tip

We use this in our pull request GitHub Action, check out a recent pull request to see it in action!


Contributors

Thanks goes to these wonderful people (emoji key):


Olavo Parno

🤔 💻 ⚠️

nothingismagick

🤔 🐛 🖋

Dave Fisher

🐛

Martin Zagora

🤔 🐛

Victor Miti

🐛

Stefan Huber

💬 📖

Guilherme Ventura

🤔 💻 🐛

Matt Hodges

🐛

Antoine Vendeville

🐛

Oleg Dutchenko

🐛

Thomas

🤔

Troy Poulter

💻 🤔 ⚠️

LiaoLiao

🤔

David Mimnagh

🤔

Micael Levi L. Cavalcante

🤔 💻 🐛

Richard Michael Coo

🐛

Letícia Vidal

🐛

This project follows the all-contributors specification. Contributions of any kind welcome!


License

Istanbul Badges Readme is MIT licensed.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].