Skip to content

GitHub Target ​

The GitHub target publishes test results as comments on GitHub pull requests. It supports both functional test results and performance test results with rich formatting and customizable content.

GitHub Target

Overview ​

This target automatically posts test summaries to GitHub PR comments, making it easy for teams to review test results directly in their pull request workflow. It can create new comments or update existing ones based on configuration.

Configuration ​

Basic Configuration ​

json
{
  "targets": [
    {
      "name": "github",
      "inputs": {
        "token": "your-github-token"
      }
    }
  ]
}

TIP

GITHUB_TOKEN is automatically set by GitHub Actions. You can use it by passing it as an argument to the publish command.

yaml
- name: Publish Results
  run: npx testbeats publish --github {GITHUB_TOKEN} --junit 'results/junit.xml'
  env:
    GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Complete Configuration ​

json
{
  "targets": [
    {
      "name": "github",
      "inputs": {
        "token": "your-github-token",
        "owner": "your-org",
        "repo": "your-repo",
        "pull_number": "123",
        "title": "Custom Test Title",
        "title_suffix": "- Build #456",
        "title_link": "https://your-ci-system.com/build/456",
        "include_suites": true,
        "include_failure_details": true,
        "only_failures": false,
        "max_suites": 10,
        "duration": "long",
        "publish": "test-summary"
      }
    }
  ]
}

Input Parameters ​

ParameterTypeDefaultDescription
tokenstringundefinedGitHub personal access token or use GITHUB_TOKEN environment variable
ownerstringundefinedGitHub repository owner (auto-detected in GitHub Actions)
repostringundefinedGitHub repository name (auto-detected in GitHub Actions)
pull_numberstringundefinedPull request number (auto-detected in GitHub Actions)
titlestringundefinedCustom title for the test results (defaults to result name)
title_suffixstringundefinedAdditional text to append to the title
title_linkstringundefinedURL to make the title clickable
include_suitesbooleantrueWhether to include individual suite results
include_failure_detailsbooleanfalseWhether to include detailed failure information
only_failuresbooleanfalseWhether to show only failed suites
max_suitesnumber10Maximum number of suites to display
durationstring"long"Duration format: "long", "short", or "ms"
publishstring"test-summary"Publish mode: "test-summary", "test-summary-slim", or "failure-details"

Publish Modes ​

test-summary (default) ​

Complete test summary with suites and configurable details.

test-summary-slim ​

Compact summary without individual suite details (sets include_suites: false).

failure-details ​

Focused on failure information (sets include_failure_details: true).

Usage Examples ​

Basic Usage in GitHub Actions ​

yaml
name: Tests
on:
  pull_request:

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - name: Run Tests
        run: npm test
      - name: Publish Results
        run: npx testbeats publish --github {GITHUB_TOKEN} --junit 'results/junit.xml'
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

With Custom Comment Title ​

json
{
  "targets": [
    {
      "name": "github",
      "inputs": {
        "title": "đź§Ş E2E Test Results",
        "include_failure_details": true
      }
    }
  ]
}

Released under the MIT License.