Skip to content
You're viewing an older version of this GitHub Action. Do you want to see the latest version instead?
percent

GitHub Action

Jest Coverage Commenter

v1

Jest Coverage Commenter

percent

Jest Coverage Commenter

Comment on PRs with Jest Coverage Information

Installation

Copy and paste the following snippet into your .yml file.

              

- name: Jest Coverage Commenter

uses: dkershner6/jest-coverage-commenter-action@v1

Learn more about this action in dkershner6/jest-coverage-commenter-action

Choose a version

Jest Coverage Commenter GitHub Action

GitHub Action to create a PR comment detailing how well test files are covering code. You can run whatever test command you want, but make sure it uses the coverage reporter to match your reporter input (see below).

Usage

Inputs

key default required description
github_token n/a true A GitHub Token, the standard one is great.
test_command npx jest --coverage false The test command to run, that also runs coverage appropriately
reporter text false Possible types: text, text-summary. Set your --coverageReporters to match. text-summary should be used on large projects.
comment_prefix ## Jest Coverage false The message preceeding coverage report

Outputs

None

Example Workflow

on: pull_request

jobs:
  test-coverage:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v2
        with:
          fetch-depth: 0
      - run: npm i

      - name: Comment with Test Coverage
        uses: dkershner6/jest-coverage-commenter-action@v1
        with:
          github_token: "${{ secrets.GITHUB_TOKEN }}"
          test_command: "npm run test:coverage"

Reporter

For the standard text reporter, the most common jest coverageReporter, the comment on the PR looks like this, with expandable details:

image

For the text-summary reporter, you should run a jest command that includes --coverageReporters=text-summary. When this occurs and the reporter input is also set to text-summary, the PR comments looks like this:

image