fork PR 触发的 workflow 令牌只读,无法创建 Check,需拆成 CI 上传 artifact + workflow_run 报告两个 workflow;测试必须先配置对应 reporter 产出 XML/JSON(如 jest-junit、dotnet test --logger trx);path 匹配到的结果文件必须格式一致,且 max-annotations 不得超过 50
test-reporter
dornyMIT活跃维护在 GitHub Actions 里直接展示 Jest、Mocha 等主流测试框架的运行结果,把通过和失败的用例汇总成可读报告,省去翻日志找失败原因。
Displays test results from popular testing frameworks directly in GitHub
- uses: dorny/test-reporter@v3
with:
name: JEST Tests
path: reports/jest-*.xml
reporter: jest-junitREADME 未说明,作为 GitHub Action 在 GitHub 托管 runner 上运行
把各语言测试框架的 XML/JSON 结果直接渲染成 GitHub Check 报告和注解
在 GitHub Actions 里直接展示 Jest、Mocha 等主流测试框架的运行结果,把通过和失败的用例汇总成可读报告,省去翻日志找失败原因。
核心能力
- 解析 XML/JSON 测试结果生成 Check Run 与 Job Summary
- 按失败消息和堆栈在代码行上生成注解
- 输出 conclusion 及 passed/failed/skipped 计数
- 支持从 artifact 下载结果,适配 fork PR 只读令牌场景
- 可限制注解数量、折叠详情、仅生成摘要
容易踩的坑
- v3.0.0最新正式版2026-03-21 · 2026-03-21 13:52 UTC
Note: The v3 release requires NodeJS 24 runtime on GitHub Actions runners.
What's Changed
- Upgrade action runtime to Node.js 24 by @dav-tb in https://github.com/dorny/test-reporter/pull/738
- Explicitly use lowest permissions required to run workflow by @jozefizso in https://github.com/dorny/test-reporter/pull/745
Other Changes
- Bump @typescript-eslint/parser from 8.57.0 to 8.57.1 by @dependabot[bot] in https://github.com/dorny/test-reporter/pull/742
- Bump @types/adm-zip from 0.5.7 to 0.5.8 by @dependabot[bot] in https://github.com/dorny/test-reporter/pull/743
- Bump flatted from 3.4.1 to 3.4.2 by @dependabot[bot] in https://github.com/dorny/test-reporter/pull/744
New Contributors
- @dav-tb made their first contribution in https://github.com/dorny/test-reporter/pull/738
Full Changelog: https://github.com/dorny/test-reporter/compare/v2.7.0...v3.0.0
- v2.7.02026-03-21 · 2026-03-21 13:50 UTC
查看更新说明
What's Changed
- Feature: Add
slug-prefixoutput for link anchors https://github.com/dorny/test-reporter/pull/731 - Feature: Report
jest-junittestsuite errors as failures https://github.com/dorny/test-reporter/pull/155 - Security: Update dependencies to fix reported security vulnerabilities
Other Changes
- Bump eslint from 9.39.3 to 9.39.4 by @dependabot[bot] in https://github.com/dorny/test-reporter/pull/732
- Bump @typescript-eslint/parser from 8.56.1 to 8.57.0 by @dependabot[bot] in https://github.com/dorny/test-reporter/pull/733
- Bump jest from 30.2.0 to 30.3.0 by @dependabot[bot] in https://github.com/dorny/test-reporter/pull/734
- Bump undici from 6.23.0 to 6.24.1 by @dependabot[bot] in https://github.com/dorny/test-reporter/pull/736
- Update
flattedpackage to v3.4.1 to fix a vulnerability by @jozefizso in https://github.com/dorny/test-reporter/pull/739
New Contributors
- @dt-thomas-durand made their first contribution in https://github.com/dorny/test-reporter/pull/731
- @johnbartholomew made their first contribution in https://github.com/dorny/test-reporter/pull/155
Full Changelog: https://github.com/dorny/test-reporter/compare/v2.6.0...v2.7.0
- Feature: Add
- v2.6.02026-03-03 · 2026-03-03 11:09 UTC
查看更新说明
We updated all dependency packages to latest versions to fix reported security vulnerabilities.
What's Changed
- Fix: For
workflow_runevents, resolve the commit of the check run from related pull request head commits first (matchingworkflow_run.head_branch, then first PR), and fall back toworkflow_run.head_shafor non-PR runs https://github.com/dorny/test-reporter/pull/673 - Change: The
test-reporteraction will listed all artifacts associated with the build run https://github.com/dorny/test-reporter/pull/693 - Maintenance: Upgrade to ESLint v9 https://github.com/dorny/test-reporter/pull/629
New Contributors
- @azchohfi made their first contribution in https://github.com/dorny/test-reporter/pull/673
Full Changelog: https://github.com/dorny/test-reporter/compare/v2.5.0...v2.6.0
- Fix: For
- v2.5.02026-01-03 · 2026-01-03 13:44 UTC
查看更新说明
What's Changed
Features
- Add Nette Tester JUnit Reporter by @jozefizso in https://github.com/dorny/test-reporter/pull/707
Project maintanance
- Bump actions/upload-artifact from 5 to 6 by @dependabot[bot] in https://github.com/dorny/test-reporter/pull/695
Full Changelog: https://github.com/dorny/test-reporter/compare/v2.4.0...v2.5.0
- v2.4.02026-01-01 · 2026-01-01 16:17 UTC
查看更新说明
What's Changed
- Create tests for sample JUnit files by @jozefizso in https://github.com/dorny/test-reporter/pull/701
- Support for the PHPUnit dialect of JUnit by @mbeccati in https://github.com/dorny/test-reporter/pull/422
- Use
String.substring()function by @jozefizso in https://github.com/dorny/test-reporter/pull/704
New Contributors
- @mbeccati made their first contribution in https://github.com/dorny/test-reporter/pull/422
Full Changelog: https://github.com/dorny/test-reporter/compare/v2.3.0...v2.4.0
用户点评
登录用户的真实使用记录,可按版本和硬件筛选还没有人点评。第一个说出真实体验的人最有价值。
Test Reporter
This Github Action displays test results from popular testing frameworks directly in GitHub.
✔️ Parses test results in XML or JSON format and creates nice report as GitHub Check Run or GitHub Actions job summaries
✔️ Annotates code where it failed based on message and stack trace captured during test execution
✔️ Provides final conclusion and counts of passed, failed and skipped tests as output parameters
How it looks:
![]() | ![]() | ![]() | ![]() |
|---|
Supported languages / frameworks:
- .NET / dotnet test ( xUnit / NUnit / MSTest )
- Dart / test
- Flutter / test
- Go / go test
- Java / JUnit
- JavaScript / JEST / Mocha
- Python / pytest / unittest
- PHP / PHPUnit / Nette Tester
- Ruby / RSpec
- Swift / xUnit
- Unreal Engine / Automation Tests
For more information see Supported formats section.
Do you miss support for your favorite language or framework? Please create Issue or contribute with PR.
Example
Following setup does not work in workflows triggered by pull request from forked repository. If that's fine for you, using this action is as simple as:
on:
pull_request:
push:
permissions:
contents: read
actions: read
checks: write
jobs:
build-test:
name: Build & Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6 # checkout the repo
- run: npm ci # install packages
- run: npm test # run tests (configured to use jest-junit reporter)
- name: Test Report
uses: dorny/test-reporter@v3
if: ${{ !cancelled() }} # run this step even if previous step failed
with:
name: JEST Tests # Name of the check run which will be created
path: reports/jest-*.xml # Path to test results
reporter: jest-junit # Format of test results
Recommended setup for public repositories
Workflows triggered by pull requests from forked repositories are executed with read-only token and therefore can't create check runs. To workaround this security restriction, it's required to use two separate workflows:
CIruns in the context of the PR head branch with the read-only token. It executes the tests and uploads test results as a build artifactTest Reportruns in the context of the repository main branch with read/write token. It will download test results and create reports
The second workflow will only run after it has been merged into your default branch (typically main or master), it won't run in a PR unless after the workflow file is part of that branch.
PR head branch: .github/workflows/ci.yml
name: 'CI'
on:
pull_request:
jobs:
build-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6 # checkout the repo
- run: npm ci # install packages
- run: npm test # run tests (configured to use jest-junit reporter)
- uses: actions/upload-artifact@v7 # upload test results
if: ${{ !cancelled() }} # run this step even if previous step failed
with:
name: test-results
path: jest-junit.xml
default branch: .github/workflows/test-report.yml
name: 'Test Report'
on:
workflow_run:
workflows: ['CI'] # runs after CI workflow
types:
- completed
permissions:
contents: read
actions: read
checks: write
jobs:
report:
runs-on: ubuntu-latest
steps:
- uses: dorny/test-reporter@v3
with:
artifact: test-results # artifact name
name: JEST Tests # Name of the check run which will be created
path: '*.xml' # Path to test results (inside artifact .zip)
reporter: jest-junit # Format of test results
Usage
- uses: dorny/test-reporter@v3
with:
# Name or regex of artifact containing test results
# Regular expression must be enclosed in '/'.
# Values from captured groups will replace occurrences of $N in report name.
# Example:
# artifact: /test-results-(.*)/
# name: 'Test report $1'
# -> Artifact 'test-result-ubuntu' would create report 'Test report ubuntu'
artifact: ''
# Name of the Check Run which will be created
name: ''
# Comma-separated list of paths to test results
# Supports wildcards via [fast-glob](https://github.com/mrmlnc/fast-glob)
# All matched result files must be of the same format
path: ''
# The fast-glob library that is internally used interprets backslashes as escape characters.
# If enabled, all backslashes in provided path will be replaced by forward slashes and act as directory separators.
# It might be useful when path input variable is composed dynamically from existing directory paths on Windows.
path-replace-backslashes: 'false'
# Format of test results. Supported options:
# dart-json
# dotnet-nunit
# dotnet-trx
# flutter-json
# golang-json
# java-junit
# jest-junit
# mocha-json
# phpunit-junit
# python-xunit
# rspec-json
# swift-xunit
# unreal-json
reporter: ''
# Allows you to generate only the summary.
# If enabled, the report will contain a table listing each test results file and the number of passed, failed, and skipped tests.
# Detailed listing of test suites and test cases will be skipped.
only-summary: 'false'
# Allows you to generate reports for Actions Summary
# https://github.blog/2022-05-09-supercharging-github-actions-with-job-summaries/
use-actions-summary: 'true'
# Optionally specify a title (Heading level 1) for the report. Leading and trailing whitespace are ignored.
# This is useful for separating your test report from other sections in the build summary.
# If omitted or set to whitespace/empty, no title will be printed.
report-title: ''
# Customize the title of badges shown for each Actions Summary.
# Useful when distinguish summaries for tests ran in multiple Actions steps.
badge-title: 'tests'
# Limits which test suites are listed:
# all
# failed
# none
list-suites: 'all'
# Limits which test cases are listed:
# all
# failed
# none
list-tests: 'all'
# Limits which test result files are listed:
# all
# failed
# none
list-files: 'all'
# Limits number of created annotations with error message and stack trace captured during test execution.
# Must be less or equal to 50.
max-annotations: '10'
# Set action as failed if test report contains any failed test
fail-on-error: 'true'
# Set this action as failed if no test results were found
fail-on-empty: 'true'
# Controls whether test report details are collapsed or expanded.
# Supported options:
# auto: Collapse only if all tests pass (default behavior)
# always: Always collapse the report details
# never: Always expand the report details
collapsed: 'auto'
# Relative path under $GITHUB_WORKSPACE where the repository was checked out.
working-directory: ''
# Personal access token used to interact with Github API
# Default: ${{ github.token }}
token: ''
Output parameters
| Name | Description |
|---|---|
| conclusion | success or failure |
| passed | Count of passed tests |
| failed | Count of failed tests |
| skipped | Count of skipped tests |
| time | Test execution time [ms] |
| url | Check run URL |
| url_html | Check run URL HTML |
| summary_file | Path to a file containing the generated test report summary in Markdown format |
| slug_prefix | Random anchor links slug prefix generated for the summary headers |
Supported formats
Test run must be configured to use JSON reporter.
You can configure it in dart_test.yaml:
file_reporters:
json: reports/test-results.json
Or with CLI arguments:
dart test --file-reporter="json:test-results.json"
For more information see:
Test execution must be configured to produce Visual Studio Test Results files (TRX). To get test results in TRX format you can execute your tests with CLI arguments:
dotnet test --logger "trx;LogFileName=test-results.trx"
Or you can configure TRX test output in *.csproj or Directory.Build.props:
<PropertyGroup>
<VSTestLogger>trx%3bLogFileName=$(MSBuildProjectName).trx</VSTestLogger>
<VSTestResultsDirectory>$(MSBuildThisFileDirectory)/TestResults/$(TargetFramework)</VSTestResultsDirectory>
</PropertyGroup>
Supported testing frameworks:
For more information see dotnet test
Test execution must be configured to generate NUnit3 XML test results.
Install the NUnit3TestAdapter package (required; it registers the nunit logger for dotnet test), then run tests with:
dotnet test --logger "nunit;LogFileName=test-results.xml"
Supported testing frameworks:
For more information see dotnet test
Test run must be configured to use JSON reporter.
You can configure it in dart_test.yaml:
file_reporters:
json: reports/test-results.json
Or with (undocumented) CLI argument:
flutter test --machine > test-results.json
According to documentation dart_test.yaml should be at the root of the package, next to the package's pubspec.
On current stable and beta channels it doesn't work, and you have to put dart_test.yaml inside your test folder.
On dev channel, it's already fixed.
For more information see:
You must use the -json flag and output the results to a file (ex: go test -json > testresults.json)
Support for JUnit XML is experimental - should work but it was not extensively tested. To have code annotations working properly, it's required your directory structure matches the package name. This is due to the fact Java stack traces don't contain a full path to the source file. Some heuristic was necessary to figure out the mapping between the line in the stack trace and an actual source file.
PHPUnit can generate JUnit XML via CLI:
phpunit --log-junit reports/phpunit-junit.xml
Nette Tester can generate JUnit XML via CLI:
tester -s -o junit tests/ > reports/tester-junit.xml
Note: Nette Tester's JUnit output doesn't include test suite names. The parser will use the report file name as the suite name and automatically group tests by directory structure.
JEST testing framework support requires the usage of jest-junit reporter.
It will create test results in Junit XML format which can be then processed by this action.
You can use the following example configuration in package.json:
"scripts": {
"test": "jest --ci --reporters=default --reporters=jest-junit"
},
"devDependencies": {
"jest": "^26.5.3",
"jest-junit": "^12.0.0"
},
"jest-junit": {
"outputDirectory": "reports",
"outputName": "jest-junit.xml",
"ancestorSeparator": " › ",
"uniqueOutputName": "false",
"suiteNameTemplate": "{filepath}",
"classNameTemplate": "{classname}",
"titleTemplate": "{title}"
}
Configuration of uniqueOutputName, suiteNameTemplate, classNameTemplate, titleTemplate is important for proper visualization of test results.
Mocha testing framework support requires:
For Mocha >= v9.1.0, you can use the following example configuration in package.json:
"scripts": {
"test": "mocha --reporter json --reporter-option output=test-results.json"
}
For Mocha < v9.1, the command should look like this:
"scripts": {
"test": "mocha --reporter json > test-results.json"
}
Additionally, test processing might fail if any of your tests write anything on standard output.
Before version v9.1.0, Mocha doesn't have the option to store json output directly to the file, and we have to rely on redirecting its standard output (mocha#4607).
Please update Mocha to version v9.1.0 or above if you encounter this issue.
Support for Python test results in xUnit format is experimental - should work but it was not extensively tested.
For pytest support, configure JUnit XML output and run with the --junit-xml option, which also lets you specify the output path for test results.
pytest --junit-xml=test-report.xml
For unittest support, use a test runner that outputs the JUnit report format, such as unittest-xml-reporting.
RSpec testing framework support requires the usage of JSON formatter.
You can configure RSpec to output JSON format by using the --format json option and redirecting to a file:
rspec --format json --out rspec-results.json
Or configure it in .rspec file:
--format json
--out rspec-results.json
For more information see:
Support for Swift test results in xUnit format is experimental - should work but it was not extensively tested.
Supports Unreal Engine Automation tests
- See more details here
GitHub limitations
Unfortunately, there are some known issues and limitations caused by GitHub API:
- Test report (i.e. build summary) is Markdown text. No custom styling or HTML is possible.
- Maximum report size is 65535 bytes. Input parameters
list-suitesandlist-testswill be automatically adjusted if max size is exceeded. - Test report can't reference any additional files (e.g. screenshots). You can use
actions/upload-artifact@v4to upload them and inspect them manually. - Check Runs are created for specific commit SHA. It's not possible to specify under which workflow test report should belong if more workflows are running for the same SHA. Thanks to this GitHub "feature" it's possible your test report will appear in an unexpected place in GitHub UI. For more information, see #67.
See also
- paths-filter - Conditionally run actions based on files modified by PR, feature branch, or pushed commits
License
The scripts and documentation in this project are released under the MIT License



