sincecutoff.com
← all changes

Playwright test.abort() aborts the running test

Introduced 2026-05-11 · score 0.94

HOW TO USE IT

When a fixture, hook, or route handler detects unrecoverable misuse, call `test.abort()` to fail the running test immediately; in a route handler, also call `route.abort()` if the request should be stopped.

test('does not publish to the shared page', async ({ page }) => { await page.route('**/publish', route => { test.abort('Tests must not publish to the shared page. Use the `clone` option.'); return route.abort(); }); });

WHY THIS HELPS

Stop a test immediately when a fixture, hook, or route handler detects unrecoverable misuse.

REQUIREMENTS AND LIMITATIONS

  • Version: v1.60.0
  • message (optional string): Describes the abort reason; included in the failure error.
  • route.abort(): Aborts the intercepted request; the API also supports an optional error code.
  • Prerequisite: `test.abort()` was added in Playwright v1.60.
  • The optional message accompanies the abort.

FIRST-PARTY EVIDENCE

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

Report a problem with this card