jest-coverage-badge
v1.0.0
Published
Create simple coverage badge for your coverage reports
Downloads
1,083
Maintainers
Readme
Jest Coverage Badge
Creates simple code coverage badges for your test reports.
Generated badges will be like the following:
'badges/branches-badge.svg':
'badges/functions-badge.svg':
'badges/statements-badge.svg':
'badges/lines-badge.svg':
'badges/average-badge.svg':
The coverage badge is calculated as the average of the percentages of: branches, lines, statements and functions
How to generate badges
- First, you need to install the package as dev dependency:
yarn add -D jest-coverage-badge // or npm i --save-dev jest-coverage-badge
- Add a script to your
package.json
to generate the badges:{ ... "scripts: { "badge": "jest-coverage-badge" // or alternatively, you can place after the tests, in this way // the badges will be generated each time you'll run the test suite "test": "jest --coverage && jest-coverage-badge" } ... }
- Add to your
jest.config.js
thejson-summary
report:{ ... "coverageReporters: [ "json-summary" ] ... }
- Generate the badges:
yarn badge // or npm run badge
- Include generated badges wherever you want. You can place them at the top of your READE.md
![average-badge.svg](<YOUR_REPO>/badges/average-badge.svg)
Licence
*MIT License