Skip to Content
GuidesReporters

Reporters

Reporters control how TSTyche formats test results.

Usage

To specify a reporter, pass it with the --reporters command line option:

tstyche --reporters list,tstyche-reporter,./custom-reporter.js

Or use the reporters configuration option:

{ "reporters": ["list", "tstyche-reporter", "./custom-reporter.js"] }

Built-in Reporters

By default, TSTyche uses the list and summary reporters.

dot

Prints a row of dots (·) for passing test files and crosses (×) for failed ones. Failures are listed at the end of the run.

list

Prints the status followed by the file name for each test file. Failures are listed immediately after the file finishes.

For single-file runs or when --verbose is enabled, the reporter includes the full test tree.

summary

Prints a concise summary of the test run. Failure details are omitted. In watch mode, the reporter produces no output.

Custom Reporter

A custom reporter can be a package or a local module.

If you are publishing your reporter to npm, use the following naming pattern: tstyche-*-reporter.

The module must export a class that implements the on() method. The constructor receives resolvedConfig as its argument:

export default class CustomReporter { /** * @param {import("tstyche/api").ResolvedConfig} resolvedConfig */ constructor(resolvedConfig) { this.resolvedConfig = resolvedConfig; } /** * @param {import("tstyche/api").ReporterEvent} reporterEvent */ on([event, payload]) { if (event === "run:start") { console.info("Hello from custom reporter!"); for (const task of payload.result.tasks) { console.info(task.filePath); } } } }

The example above handles the run:start event, which is emitted once at the beginning of a test run. For a full list of events, see the Event type.

Last updated on