Optimize Your CI/CD Pipeline
Get instant insights into your CI/CD performance and costs. Reduce build times by up to 45% and save on infrastructure costs.
name: 'Usage of test-reporter GitHub Action'
on:
push:
branches:
- main
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: npm ci
- run: npm test
- name: Test Report
uses: dorny/test-reporter@v1
if: success() || failure()
with:
name: JEST Tests
path: reports/jest-*.xml
reporter: jest-junit
Test Reporter
Displays test results from popular testing frameworks directly in GitHub
What is Test Reporter GitHub Action?
The Test Reporter GitHub Action displays test results from popular testing frameworks directly in GitHub. It parses test results in XML or JSON format and creates a detailed report as a GitHub Check Run.
How to Display Test Results in GitHub Actions for Public Repositories
For public repositories, workflows triggered by pull requests from forked repositories are executed with a read-only token and therefore can't create check runs. To work around this security restriction, it is required to use two separate workflows:
name: 'CI'
on:
pull_request:
jobs:
build-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: npm ci
- run: npm test
- uses: actions/upload-artifact@v4
if: success() || failure()
with:
name: test-results
path: jest-junit.xml
name: 'Test Report'
on:
workflow_run:
workflows: ['CI']
types:
- completed
permissions:
contents: read
actions: read
checks: write
jobs:
report:
runs-on: ubuntu-latest
steps:
- uses: dorny/test-reporter@v1
with:
artifact: test-results
name: JEST Tests
path: '*.xml'
reporter: jest-junit
How to Specify Artifact
Name or regex of artifact containing test results. Regular expression must be enclosed in /
.
with:
artifact: /test-results-(.*)/
name: 'Test report $1'
How to Specify Check Run Name
The name of the Check Run which will be created.
with:
name: 'Test Results'
How to Specify Path to Test Results
Comma-separated list of paths to test results. Supports wildcards via fast-glob.
with:
path: 'test-results/**/*.xml'
How to Replace Backslashes in Path
If enabled, all backslashes in the provided path will be replaced by forward slashes.
with:
path-replace-backslashes: 'true'
How to Specify Reporter
Format of test results. Supported options: dart-json
, dotnet-trx
, flutter-json
, java-junit
, jest-junit
, mocha-json
, rspec-json
.
with:
reporter: 'jest-junit'
How to Generate Only Summary
Allows you to generate only the summary of the test results.
with:
only-summary: 'true'
How to List Test Suites
Limits which test suites are listed. Options: all
, failed
.
with:
list-suites: 'failed'
How to List Test Cases
Limits which test cases are listed. Options: all
, failed
, none
.
with:
list-tests: 'failed'
How to Limit Annotations
Limits number of created annotations with error message and stack trace captured during test execution. Must be less or equal to 50.
with:
max-annotations: '10'
How to Fail on Error
Set action as failed if the test report contains any failed test.
with:
fail-on-error: 'true'
How to Fail on Empty
Set this action as failed if no test results were found.
with:
fail-on-empty: 'true'
How to Set Working Directory
Relative path under $GITHUB_WORKSPACE
where the repository was checked out.
with:
working-directory: 'subdirectory'
How to Set GitHub Token
Personal access token used to interact with the GitHub API.
with:
token: ${{ secrets.GITHUB_TOKEN }}