Skip to content

Kevin-Bronsdijk/jest-coverage-report-action

Repository files navigation

jest coverage report 🧪

PR Comment example

A GitHub action that reports about your code coverage in every pull request.

MIT License Issues

This action uses Jest to extract code coverage, and comments it on pull request. Inspired by Size-limit action. Features:

  • Commenting pull request with current code coverage.
  • Comparing coverage with base branch.
  • Showing spoiler in the comment for all new covered files.
  • Showing spoiler in the comment for all files, in which coverage was reduced.

Usage

  1. Install and configure Jest.
  2. Create new action inside .github/workflows:
name: 'coverage'
on:
    pull_request:
        branches:
            - master
jobs:
    coverage:
        runs-on: ubuntu-latest
        env:
            CI_JOB_NUMBER: 1
        steps:
            - uses: actions/checkout@v1
            - uses: artiomtr/jest-coverage-report-action@v1
              with:
                  github_token: ${{ secrets.GITHUB_TOKEN }}
  1. That's it!

Customizing test script

By default, this action will run this command, to extract coverage:

npx jest --silent --coverage --coverageReporters="text" --coverageReporters="text-summary"

If you're not satisfied with default behaviour, you can specify your own command, by passing custom option test_script

For instance, if you want to run test:coverage npm script:

with:
    github_token: ${{ secrets.GITHUB_TOKEN }}
    test_script: npm run test:coverage

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

MIT © Artiom Tretjakovas

About

Track your code coverage in each pull request.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • TypeScript 96.5%
  • JavaScript 3.2%
  • Dockerfile 0.3%