Coverage Badge Creator creates badges based on your test coverage and inserts them into the README
npm install coverage-badge-creator
![CI][ci]
![Build][build]
![Code-Style][code-style]
[![MIT License][license-shield]][license-url]
[![Release][release-shield]][release-url]
![Maintenance][maintained-shield]
npm:sh
npm install --save-dev coverage-badge-creator
`
yarn:
`sh
yarn add --dev coverage-badge-creator
`Usage
1. First you need to set up your test environment.
* jest
> In jest config you need to add 'json-summary' to coverageReporters. https://jestjs.io/docs/en/configuration
* mocha
`sh
{
"test": "nyc --reporter=json-summary mocha"
}
`
2. Insert one of the following keys anywhere in your README. These will be replaced by the coverage-badge-creator with the appropriate badge. The following keys are available:
* $coverage$
* $statements$
* $branches$
* $functions$
* $lines$
_important are also the surrounding dollar signs_
3. Now you can create the badges.
Add the command to your package.json scripts block:
`json
"scripts": {
"coverage:badge": "coverage-badge-creator",
}
`
and run it from the CLI:
`sh
npm run coverage:badge
`
Config
There are various ways to configure the badges according to your wishes. To do this, you only need to create a new file called .badge-config. Then you have the following options: _For a simple example click here._
$3
`
{
coverage_file_path: './coverage/json-summary.json'
}
`$3
`
{
badges: {
coverage: {
logo: 'foo'
color: 'bar'
}
}
}
`
Depending on your test tool, you will probably have the following badges available for configuration:
* coverage
* statements
* branches
* functions
* lines
Options
* style
![plastic][style-plastic] ![flat][style-flat] ![flat-square][style-flat-square] ![flat-for-the-badge][style-for-the-badge] ![social][style-social]
* logo
![kotlin][logo-kotlin] ![medium][logo-medium] ![github][logo-github]
* logoColor
![blue][logo-blue] ![green][logo-green] ![white][logo-black]
* color
![blue][color-blue] ![green][color-green] ![white][color-black]
* link
![blue][link-github] ![green][link-medium] ![white][link-reddit]
_For more information on all options, see -> _$3
In addition, you have further options in the cli.* --config
> This allows you to change the path and name of the configuration file.
`sh
"scripts": {
"coverage:badge": "coverage-badge-creator --config './badge-coverage-config.json'",
}
`Requirements
* Node > v10.0.0
Built With
This section lists all programming languages and main frameworks.
* Node
* Typescript
* Jest
Contributing
Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.1. Fork the Project
2. Create your Feature Branch (
git checkout -b feature/new_feature)
3. Commit your Changes (git commit -m 'feat: Add new feature')
4. Push to the Branch (git push origin feature/new_feature)
5. Open a Pull Request
License
Distributed under the MIT License. See LICENSE` for more information.
[style-plastic]: https://img.shields.io/badge/plastic-83A603.svg?style=plastic
[style-flat]: https://img.shields.io/badge/flat-83A603.svg?style=flat
[style-flat-square]: https://img.shields.io/badge/flat_square-83A603.svg?style=flat-square
[style-for-the-badge]: https://img.shields.io/badge/for_the_badge-83A603.svg?style=for-the-badge
[style-social]: https://img.shields.io/badge/social-83A603.svg?style=social
[logo-github]: https://img.shields.io/badge/logo-github.svg?logo=github
[logo-kotlin]: https://img.shields.io/badge/logo-kotlin.svg?logo=kotlin
[logo-medium]: https://img.shields.io/badge/logo-medium.svg?logo=medium
[logo-blue]: https://img.shields.io/badge/blue-83A603.svg?logo=github&logoColor=blue
[logo-green]: https://img.shields.io/badge/green-83A603.svg?logo=kotlin&logoColor=green
[logo-black]: https://img.shields.io/badge/black-83A603.svg?logo=medium&logoColor=black
[color-blue]: https://img.shields.io/badge/blue-83A603.svg?color=blue
[color-green]: https://img.shields.io/badge/green-83A603.svg?green=green
[color-black]: https://img.shields.io/badge/black-83A603.svg?color=black
[link-github]: https://img.shields.io/badge/Github-83A603.svg?link=https://github.com/
[link-medium]: https://img.shields.io/badge/Medium-83A603.svg?link=https://medium.com/
[link-reddit]: https://img.shields.io/badge/Reddit-83A603.svg?link=https://www.reddit.com/
[ci]: https://github.com/H3nSte1n/coverage-badge-creator/workflows/CI/badge.svg?style=flat
[build]: https://github.com/H3nSte1n/coverage-badge-creator/workflows/Build/badge.svg?style=flat
[code-style]: https://github.com/H3nSte1n/coverage-badge-creator/workflows/Code-Style/badge.svg?style=flat
[maintained-shield]: https://img.shields.io/badge/Maintained%3F-yes-green.svg?style=flat
[release-shield]: https://img.shields.io/github/release/H3nSte1n/coverage-badge-creator.svg?style=flat
[release-url]: https://GitHub.com/H3nSte1n/coverage-badge-creator/releases/
[issues-shield]: https://img.shields.io/github/issues/H3nSte1n/coverage-badge-creator.svg?style=flat
[issues-url]: https://github.com/H3nSte1n/coverage-badge-creator/issues
[license-shield]: https://img.shields.io/badge/License-MIT-yellow.svg?style=flat
[license-url]: https://github.com/H3nSte1n/coverage-badge-creator/blob/master/LICENSE