close

Reporters

Reporters in Rstest control how test results are displayed and processed.

You can use built-in reporters to get different output formats or create custom reporters to integrate with your workflow.

Using reporters

You can configure reporters through:

  1. CLI: --reporter=<name> (can be used multiple times)
  2. Config file: Add reporters to your rstest.config.ts
import { defineConfig } from '@rstest/core';
import { customReporter } from './path/to/custom-reporter';

export default defineConfig({
  reporters: [
    'default', // Simple string reporter
    ['junit', { outputPath: './test-results.xml' }], // Reporter with options
    customReporter, // Custom reporter instance
  ],
});

More configuration options can be found in the Reporters Configuration documentation.

Reporter options for built-in reporters are defined in the TypeScript types: packages/core/src/types/reporter.ts

Built-in reporters

Rstest provides several built-in reporters:

ReporterPurposeUse case
defaultConsole output with colorsLocal development
verboseDetailed test case outputDebugging test failures
github-actionsCI error annotationsGitHub Actions workflows
junitJUnit XML formatCI/CD integration
mdMarkdown agent reportAgent / LLM integrations

Default reporter

The default reporter displays test run status, results, and summary information in your terminal with colored output.

Output example:

 test/index.test.ts (2)

 Test Files 1 passed
      Tests 2 passed
   Duration 112ms (build 19ms, tests 93ms)

Configuration options:

  • summary: Whether to display summary information (default: true)
  • logger: Custom logger function for output (default: process.stdout/process.stderr)

Verbose reporter

The verbose reporter outputs detailed information for all test cases, including successful ones. Use this when you need complete visibility into test execution.

CLI
rstest.config.ts
npx rstest --reporter=verbose

Output example:

 test/index.test.ts (2) 2ms
 Index > should add two numbers correctly (1ms)
 Index > should test source code correctly (1ms)

 Test Files 1 passed
      Tests 2 passed
   Duration 112ms (build 19ms, tests 93ms)

GitHub Actions reporter

Outputs error messages using GitHub Actions workflow commands when tests fail, enabling rich error annotations in your CI.

Auto-enablement: Automatically enabled in GitHub Actions environments.

CLI
rstest.config.ts
npx rstest --reporter=github-actions

When tests fail, the GitHub Actions reporter outputs information in a format similar to:

::error file=src/index.ts,line=4,col=17,title=test/index.test.ts > should add two numbers correctly::expected 2 to be 4

These outputs are parsed by GitHub Actions and generate comments at the corresponding locations.

rstest-github-actions-example

Auto-enablement

When no reporter is manually set, Rstest automatically enables this reporter when it detects a GitHub Actions environment (process.env.GITHUB_ACTIONS is 'true').

Manual enablement

You can also manually enable this reporter:

CLI
rstest.config.ts
npx rstest --reporter=github-actions

JUnit reporter

Generates test reports in JUnit XML format, perfect for CI/CD integration and test result aggregation.

CLI
rstest.config.ts
npx rstest --reporter=junit

Configuration options:

  • outputPath: Output file path (defaults to console output)

The JUnit reporter generates XML format as follows:

<?xml version="1.0" encoding="UTF-8"?>
<testsuites name="rstest tests" tests="3" failures="1" errors="1" skipped="1" time="0.3" timestamp="2024-01-01T00:00:00.000Z">
  <testsuite name="test1.test.ts" tests="3" failures="1" errors="1" skipped="1" time="0.3" timestamp="2024-01-01T00:00:00.000Z">
    <testcase name="should pass" classname="test1.test.ts" time="0.1">
    </testcase>
    <testcase name="should fail" classname="test1.test.ts" time="0.2">
      <failure message="Test failed" type="AssertionError">expected 'hi' to be 'hii' // Object.is equality - Expected + Received - hii + hi at test1.test.ts:10:21</failure>
    </testcase>
    <testcase name="should skip" classname="test1.test.ts" time="0.0">
      <skipped/>
    </testcase>
  </testsuite>
</testsuites>

The JUnit reporter maps test case execution status to JUnit test status:

  • pass: Test passed
  • fail: Test failed, generates <failure> tag
  • skip: Test skipped, generates <skipped> tag
  • todo: Test todo, generates <skipped> tag

Markdown reporter

The markdown reporter outputs a single markdown document to stdout, designed for agent / LLM consumption.

In agent environments, Rstest defaults to md only when you didn't explicitly configure reporters.

The default preset is normal, which is tuned for agent workflows:

  • Each failure includes a repro command (file+name) so an agent can rerun a single failing case.
  • Stack output defaults to top (a stable anchor frame) instead of full stack frames.
  • Console output is enabled by default, but limited to keep the report size under control.
  • When the number of failures exceeds failures.max, the reporter prints a full failure list with minimal fields (repro / type / message / expected / actual), and only expands full details for the first failures.max failures.
CLI
rstest.config.ts
npx rstest --reporter=md

You can further tune the output via reporter options:

rstest.config.ts
import { defineConfig } from '@rstest/core';

export default defineConfig({
  reporters: [
    [
      'md',
      {
        preset: 'normal',
        failures: { max: 50 },
        stack: 'top',
        console: { maxLogsPerTestPath: 10, maxCharsPerEntry: 500 },
      },
    ],
  ],
});

Custom reporters

For advanced integration needs, you can create custom reporters by implementing the Reporter interface.

More details can be found in the Reporter API reference.