Publish test results
Find a file
2021-01-24 17:18:27 +01:00
.github CI: use wildcard path to jest results 2021-01-16 22:54:48 +01:00
.vscode Add vscode launch configuration for jest tests 2020-10-12 22:25:12 +02:00
__tests__ Use normalizeFilePath() to unify test output on windows/Linux 2021-01-16 23:06:50 +01:00
dist Improve README and action.yml 2021-01-24 17:18:27 +01:00
reports Bump node-notifier from 8.0.0 to 8.0.1 in /reports/jest 2020-12-22 10:23:51 +01:00
src Improve logging and error handling 2021-01-18 22:21:19 +01:00
.editorconfig Add dotnet-trx fixture project 2020-10-17 21:41:49 +02:00
.eslintignore Initial commit 2020-10-01 22:53:25 +02:00
.eslintrc.json Create annotations where exceptions were thrown 2020-11-28 21:24:57 +01:00
.gitattributes Force EOL=LF 2020-11-12 23:26:27 +01:00
.gitignore Support parsing multiple reports 2021-01-16 22:53:14 +01:00
.prettierignore Configure prettier (line width: 120) 2020-11-12 23:27:48 +01:00
.prettierrc.json Configure prettier (line width: 120) 2020-11-12 23:27:48 +01:00
action.yml Improve README and action.yml 2021-01-24 17:18:27 +01:00
jest.config.js Initial commit 2020-10-01 22:53:25 +02:00
LICENSE Improve README and action.yml 2021-01-24 17:18:27 +01:00
package-lock.json Improve README and action.yml 2021-01-24 17:18:27 +01:00
package.json Improve README and action.yml 2021-01-24 17:18:27 +01:00
README.md Improve README and action.yml 2021-01-24 17:18:27 +01:00
tsconfig.json Update tsconfig.json for Node v12+ 2020-11-12 23:25:48 +01:00

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 (Github Check Run)
  • Annotates code where it failed based on message and stack trace captured during test execution
  • Sets output variable conclusion to success if all tests passed or failure if any test failed

Supported languages / frameworks:

For more information see Supported formats section.

Support is planned for:

Do you miss support for your favorite language or framework? Please create Issue or contribute with PR.

Example

jobs:
  build-test:
    name: 'Build & Test'
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2          # 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@v1
        if: always()                       # 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 report
          reporter: 'jest-junit'           # Format of test report

Usage

- uses: dorny/test-reporter@v1
  with:

    # Name of the Check Run which will be created
    name: ''

    # Path to test report
    # Supports wildcards via [fast-glob](https://github.com/mrmlnc/fast-glob)
    # Path may match multiple result files of same format
    path: ''

    # Format of test report. Supported options:
    #   dart-json
    #   dotnet-trx
    #   flutter-machine
    #   jest-junit
    reporter: ''

    # Enables code annotations with error message and stack trace
    annotations: 'true'

    # Set action as failed if test report contain any failed test
    fail-on-error: 'true'

    # 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: ''

Supported formats

dart-json

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:

dotnet-trx

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)/reports</VSTestResultsDirectory>
</PropertyGroup>

Supported testing frameworks:

For more information see dotnet test

flutter-machine

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. It works in dart projects but the file is ignored by flutter. With flutter it works when dart_test.yaml is placed inside your test folder.

For more information see:

jest-junit

JEST testing framework support requires 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 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.

License

The scripts and documentation in this project are released under the MIT License