How to Publish Test Results as a Check with GitHub Actions
A test-reporter action parses your JUnit XML and publishes a check run, so failures show inline on the PR.
Have your runner emit JUnit XML, then run dorny/test-reporter to parse it and create a check run. Failed tests are annotated directly on the pull request, which is faster to read than raw logs.
Steps
- Configure your runner to write a JUnit XML report.
- Run
dorny/test-reporter, pointingpathat the report. - Grant
checks: writeso the action can create the check run.
Workflow
.github/workflows/ci.yml
permissions:
contents: read
checks: write
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: npm ci
- run: npx jest --reporters=default --reporters=jest-junit
- uses: dorny/test-reporter@v1
if: always()
with:
name: Jest tests
path: junit.xml
reporter: jest-junitGotchas
- Use
if: always()so the report publishes even when tests fail. - From a forked PR the token is read-only; run the reporter from a
workflow_runevent instead.
Related guides
How to Enforce a Code Coverage Threshold with GitHub ActionsFail a GitHub Actions build when coverage drops below a target by setting coverageThreshold in Jest, so a reg…
How to Publish Coverage to Codecov with GitHub ActionsGenerate a coverage report in GitHub Actions and upload it to Codecov with codecov/codecov-action, using a re…