DEV Community

Cover image for Create README test coverage badges from istanbul reports
Olavo Parno
Olavo Parno

Posted on

Create README test coverage badges from istanbul reports

There are fantastic tools for coverage badges such as Coveralls but, for free, they only cover public repositories

What then if a repository is private? Bind it to a process run locally with Istanbul Readme Badges

Process

One can follow the very README.md of the project but in short here is what is needed:

  • Install it
npm i -D istanbul-badges-readme
  • A README.md file with additional markup into which the badges are inserted
| Statements                | Branches                | Functions                | Lines                |
| ------------------------- | ----------------------- | ------------------------ | -------------------- |
| ![Statements](#branches#) | ![Branches](#branches#) | ![Functions](#branches#) | ![Lines](#branches#) |
  • Run the script anywhere, either in a, e.g. pre-commit husky hook, or in a pure NPM script directly
node_modules/.bin/istanbul-badges-readme
  • Voilà!

Alt Text

Top comments (2)

Collapse
 
wakeupmh profile image
Marcos Henrique

It's useful, thanks for sharing

Collapse
 
olavoparno profile image
Olavo Parno

You rock, dude!