sincecutoff.com
← all changes

Playwright reporters can filter tests with reporter.preprocess()

Introduced 2026-07-24 · score 0.98

HOW TO USE IT

When selected tests must be skipped before the run begins, implement `Reporter.preprocess()` and call `testRun.skip(test)` for each matching test in `suite.allTests()`.

class MyReporter { async preprocess({ config, suite, testRun }) { for (const test of suite.allTests()) { if (shouldSkip(test)) // Replace with your selection condition. testRun.skip(test); } } }

WHY THIS HELPS

Skip selected tests in a reporter after configuration resolution and before the run begins.

REQUIREMENTS AND LIMITATIONS

  • Version: v1.62.0
  • config (required): Resolved configuration passed to `preprocess`.
  • suite (required): Root suite; `suite.allTests()` returns tests in it and its descendants. It reflects project, grep, and `.only` filtering; setup and dependency projects are read-only.
  • testRun (required): Controls which tests run and their expected status.
  • test (required): `TestCase` or `Suite` to skip; test bodies are not executed and tests are reported as skipped.
  • reason: Optional explanation surfaced as the annotation description by `testRun.skip(test, reason)`.
  • Prerequisite: Playwright v1.62 or later; `reporter.preprocess()` and `testRun.skip()` were added in v1.62.
  • The hook runs after configuration is resolved and before `reporter.onBegin()`.
  • The release says the hook lets reporters mark tests skipped, excluded, fixed, or failing through a `TestRun` object.

FIRST-PARTY EVIDENCE

Check the installed version and the source before using it. Entry JSON

Report a problem with this card