1.6.2 • Published 3 years ago

danger-plugin-coverage v1.6.2

Weekly downloads
300
License
MIT
Repository
github
Last release
3 years ago

danger-plugin-coverage

npm version semantic-release .github/workflows/deploy.yml

A Danger plugin to report code coverage.

This plugin detects and parses coverage reports, posting the results as a Markdown table back to the pull request.

It uses the clover.xml format, which is output by Istanbul, a coverage reporter integrated with JavaScript testing tools such as Jest and Karma.

This format can also be output by testing libraries for other languages, such as PHPUnit. So, while this is primarily intended as a tool to run against JavaScript packages it would technically work as a coverage reporter for other languages too.

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: 49.08%
Coverage threshold for functions (80%) not met: 74.46%
Impacted Files% Stmts% Branch% Funcs% LineUncovered Lines
src/module-one.js100100100100:white_check_mark:
src/module-two.js95.2433.3366.67801, 42, 1337...:x:
src/module-three.js82.3310.2544.5545.5512, 15, 32...:x:
src/module-four.js10001032.554, 65, 94...:x:
src/module-five.js100100100100:white_check_mark:
Impacted Files% Stmts% Branch% Funcs% LineUncovered Lines
src/module-six.js100100100100:white_check_mark:
src/module-seven.js100100100100:white_check_mark:

Usage

Install:

yarn add danger-plugin-coverage --dev

At a glance:

// dangerfile.js
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.

Settings

The function accepts a settings object with the following properties:

namedescription
successMessageA custom message to show when coverage is above the threshold.
failureMessageA custom message to show when coverage is below the threshold.
cloverReportPathOverride automatic coverage report detection to provide the relative path to a report.
maxRowsThe number of rows to show (additional rows will be collapsed within a <details> element).
maxCharsThe maximum number of characters to allow in a file name cell.
maxUncoveredThe maximum number of uncovered lines to show.
wrapFilenamesWrap long file names to help the table fit in a PR comment.
thresholdThe thresholds at which to show the failure messaging.
warnOnNoReportShow a warning if no coverage report was detected.

Example (defaults shown):

import coverage from 'danger-plugin-coverage';

schedule(coverage({
  successMessage: ':+1: Test coverage is looking good.',
  failureMessage: 'Test coverage is looking a little low for the files created '
    + 'or modified in this PR, perhaps we need to improve this.',
  cloverReportPath: './coverage/clover.xml',
  maxRows: 3,
  maxChars: 100,
  maxUncovered: 10,
  wrapFilenames: true,
  warnOnNoReport: true,
  showAllFiles: false,
  threshold: {
    statements: 80,
    branches: 80,
    functions: 80,
    lines: 80,
  },
}));
1.6.2

3 years ago

1.6.1

3 years ago

1.6.0

4 years ago

1.5.0

4 years ago

1.4.1

4 years ago

1.3.3

4 years ago

1.3.2

4 years ago

1.4.0

4 years ago

1.3.1

4 years ago

1.2.0

4 years ago

1.3.0

4 years ago

1.1.0

4 years ago

1.0.0

4 years ago