@adso-ts/badges
v1.1.4
Published
Jest coverage badges generator
Downloads
1,229
Maintainers
Readme
SVG badges generator for your repository
Module installs the following binary commands:
coverage-badges
- Jest test coverage badges fromcoverage-summary.json
(options: --read, --save)custom-badges
- Configurable badges frombadges.json
(options: --read, --save)version-badge
- Package version badge frompackage.json
(options: --save)
Installation:
yarn add @adso-ts/badges
Dependencies
For coverage-badges
Jest coverage report must be saved as coverage-summary.json
, thus requires the following entries in jest.config.js
are necessary:
module.exports = {
...
collectCoverage: true,
coverageReporters: ['json-summary'],
...
};
For custom-badges
A config file must be present and pointed to when executing custom-badges
command.
{
"badges": [
{
"badge_name": {
"label": "Badge label",
"value": "value to show",
"color": "hexadecimal color for value background"
}
}
]
}
Generate badges:
yarn script in package.json
"scripts": {
"coverage-badges": "coverage-badges --read=custom_path_to_coverage-summary.json --save=custom_badges_folder"
"custom-badges": "custom-badges --read=custom_path_to_badges.json --save=custom_badges_folder"
"version-badge": "version-badge --save=custom_badges_folder"
}
Console commands
yarn coverage-badges
yarn custom-badges
yarn version-badge
Parameters (optional)
read
: alternative location ofJSON
file (coverage-summary.json
orbadges.json
)save
: custom path to save badge svg files
Usage in markdown files
Jest test coverage
![Average](./badges/average.svg)
![Lines](./badges/lines.svg)
![Statements](./badges/statements.svg)
![Branches](./badges/branches.svg)
![Functions](./badges/functions.svg)
Package version
![Version](./badges/version.svg)
Custom/static badges examples
![npm](./badges/npm.svg)
![dependencies](./badges/dependencies.svg)
Results
Test coverage
Version
Custom/static badges examples