Skip to content

YakkaDev/jest-summary-reader

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Repository files navigation

Jest-Summary-Reader Github Action

Jest Coverage Latest Release Package Size Files Count Last Commit

Introduction

This GitHub Action resolves a Jest coverage-summary file into simple percentage values.

Jest-Summary-Reader based on the CommonJS engine and is limited by Github Actions.

Usage

At first, you need to edit your jest settings file and add the following lines:

coverageReporters: [
  "json-summary"
]

Then, you need to generate the coverage-summary.json file in one of the possible ways, for example, using the command line argument:

jest --coverage

Finally, you need to specify the path to this file relative to the root directory of the project in your GitHub Actions, following the example:

  steps:
    - name: Checkout repository
      uses: actions/checkout@v4

    - name: Read Jest-Summary
      id: jest-summary
      uses: YakkaDev/jest-summary-reader@v1.0.0
      with:
        path: ./coverage/coverage-summary.json
          
    - run: |
        echo Coverage Average - ${{ steps.jest-summary.outputs.average }}
        echo Coverage Functions - ${{ steps.jest-summary.outputs.functions }}
        echo Coverage Lines - ${{ steps.jest-summary.outputs.lines }}
        echo Coverage Statements - ${{ steps.jest-summary.outputs.statements }}
        echo Coverage Branches - ${{ steps.jest-summary.outputs.branches }}

Detailed information on setting up Jest can be found directly on the Jest documentation page.

Options

Below you will find all possible options of this application, as well as their description and default values.

Option Description Requried Default
path Path to coverage-summary file Yes -
format Extension of coverage-summary file No json

Outputs

Output Description
average Average percentage among all categories
functions The percentage value among all covered functions
lines The percentage value among all covered rows
statements The percentage value among all covered statements
branches The percentage value among all covered branches

Authors

The following people participated in the development:

License

This project is released under the MIT License.

Acknowledgments

The application uses a @actions/core packages.