Skip to main content
The Reporter interface allows you to create custom reporters that receive notifications about test execution events. Implement this interface to build reporters that format test results according to your needs.

Creating a Custom Reporter

Configure the reporter:

Reporter Interface

All methods are optional. Implement only the events you need.

onBegin(config, suite)

Called once before running tests. All tests have been discovered and organized into a suite hierarchy.
FullConfig
Resolved test configuration
Suite
Root suite containing all projects, files, and test cases

onTestBegin(test, result)

Called when a test begins execution.
TestCase
The test that is starting
TestResult
Test result object (initially empty, populated during execution)

onStdOut(chunk, test, result)

Called when the worker process writes to stdout.
string | Buffer
Output data
TestCase | undefined
Test that was running (may be undefined if output occurred outside a test)
TestResult | undefined
Test result object (may be undefined)

onStdErr(chunk, test, result)

Called when the worker process writes to stderr.
string | Buffer
Error output data
TestCase | undefined
Test that was running (may be undefined)
TestResult | undefined
Test result object (may be undefined)

onStepBegin(test, result, step)

Called when a test step begins.
TestCase
The test containing this step
TestResult
Test result object
TestStep
The step that is starting

onStepEnd(test, result, step)

Called when a test step completes.
TestCase
The test containing this step
TestResult
Test result object
TestStep
The completed step

onTestEnd(test, result)

Called when a test completes. The result object is fully populated at this point.
TestCase
The completed test
TestResult
Complete test result with status, errors, and timing

onError(error)

Called on global errors that occur outside of test execution.
TestError
Error object with message and optional stack trace

onEnd(result)

Called after all tests have finished or testing was interrupted. Can return a Promise.
FullResult
Overall test run result
Returns: Promise<{ status?: FullResult['status'] }> | void Reporters can override the final status:

onExit()

Called immediately before the test runner exits. All reporters have received onEnd at this point.

printsToStdio()

Indicates whether the reporter outputs to stdout/stderr. Returns: boolean Return false if your reporter doesn’t print to the terminal. Playwright will use a standard terminal reporter alongside your custom reporter.

Event Order

Typical sequence of reporter calls:
  1. onBegin(config, suite) - Called once with the root suite
  2. For each test:
    • onTestBegin(test, result) - Test starts
    • onStepBegin(test, result, step) - Each step starts
    • onStepEnd(test, result, step) - Each step completes
    • onStdOut(chunk, test, result) - Any stdout output
    • onStdErr(chunk, test, result) - Any stderr output
    • onTestEnd(test, result) - Test completes
  3. onError(error) - Any global errors
  4. onEnd(result) - All tests finished
  5. onExit() - Before runner exits

Merged Reports

When using the blob reporter with merge-reports, the same Reporter API is called. Key differences:
  • Projects from different shards are kept as separate TestProject objects
  • If a project was sharded across 5 machines, there will be 5 project instances with the same name

Error Handling

Playwright swallows errors thrown in reporter methods. If you need error detection:

Full Result Status

The status field in FullResult can be:
  • 'passed' - All tests passed as expected
  • 'failed' - At least one test failed
  • 'timedout' - Global timeout reached
  • 'interrupted' - User interrupted the run