coverage-badges
v1.0.7
Published
Create coverage badges from different coverage reports
Downloads
936
Readme
Coverage Badges
Create coverage badges from different coverage reports.
Coverage badge examples:
Installation
yarn add --dev coverage-badges
or
npm install --save-dev coverage-badges
Configuration
Create .coveragebadgesrc
file in JSON format.
Simple config example (for jest coverage)
.coveragebadgesrc
example
{
"source": "./coverage/coverage-summary.json",
"attribute": "total.statements.pct"
}
packadge.json
example
"scripts": {
"premake-badge": "$(yarn bin)/jest --coverage",
"make-badge": "$(yarn bin)/coverage-badges",
},
"jest": {
"coverageReporters": [
"text",
"lcov",
"json-summary"
],
}
Run
yarn make-badge
This config creates a coverage badge in a default directory ./badges
.
You can add ![Coverage](./badges/coverage.svg)
to your README.md after the badge creation.
Advanced config example (using multiple coverage report from jest coverage and simplecov coverage for ruby)
.coveragebadgesrc
example
[
{
"label": "JS coverage",
"source": "./coverage/coverage-summary.json",
"attribute": "total.statements.pct",
"outputDir": "./my_badges_dir"
},
{
"label": "Ruby coverage",
"source": "./coverage/.last_run.json",
"attribute": "result.covered_percent",
"outputDir": "./my_badges_dir"
}
]
packadge.json
example
"scripts": {
"premake-badges": "$(yarn bin)/jest --coverage && COVERAGE=true rails test",
"make-badges": "$(yarn bin)/coverage-badges",
},
"jest": {
"coverageReporters": [
"text",
"lcov",
"json-summary"
],
}
Run
yarn make-badges
This config creates coverage badges in the custom directory ./my_badges_dir
.
You can add ![JS coverage](./my_badges_dir/js_coverage.svg)
and ![Ruby coverage](./my_badges_dir/ruby_coverage.svg)
to your README.md after badges creation.
Author
License
MIT