danger-plugin-coverage
A Danger plugin to report code coverage.
This plugin reads coverage report in the clover.xml
format. This format is
output by various JavaScript testing libraries, such as Jest,
as well as testing libraries for other languages, such as PHPUnit.
Usage
Install:
yarn add danger-plugin-coverage --dev
At a glance:
import coverage from 'danger-plugin-coverage';
schedule(coverage());
Note that the coverage report output by your test runner must exist before Danger
is run. By default we will look for the report at coverage/clover.xml
, which
is the default output location for Jest.
Coverage will be reported as in the example below.
Coverage Report
Test coverage is looking a little low for the files created or modified in this PR, perhaps we need to improve this.
Coverage threshold for branches (80%) not met: 33.33%
Coverage threshold for functions (80%) not met: 66.67%
Settings
The function accepts a settings object with the following properties:
name | description |
---|
successMessage | A custom message to show when coverage is above the threshold. |
failureMessage | A custom message to show when coverage is bellow the threshold. |
cloverReportPath | The relative path to the clover.xml file. |
maxRows | The number of rows to show (additional rows will be collapsed within a <details> element). |
Example:
import coverage from 'danger-plugin-coverage';
schedule(coverage({
successMessage: ':+1: Test coverage is looking good.',
failureMessage: ':-1: Test coverage is not looking so good.',
cloverReportPath: './coverage/clover.xml',
maxRows: 5,
}));