reporters

  • Type:
type Reporter = ReporterName | [ReporterName, ReporterOptions];

type Reporters = Reporter | Reporter[];
  • Default:
process.env.GITHUB_ACTIONS === 'true'
  ? ['default', 'github-actions']
  : ['default'];
  • CLI: --reporter=<name> --reporter=<name1>

Customize the reporter type.

Built-in Reporters

Default reporter

By default, Rstest displays test run status, results, and summary information in the terminal.

Output example:

 test/index.test.ts (2)

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

Verbose reporter

The default reporter only outputs test case information when tests fail or run slowly. The verbose reporter will output all test case information after test completion.

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

export default defineConfig({
  reporters: 'verbose'
});

With verbose reporter, Rstest outputs:

 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

The Github Actions reporter outputs error messages in the form of workflow commands when tests fail.

Output example

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
import { defineConfig } from '@rstest/core';

export default defineConfig({
  reporters: ['github-actions']
});