October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan NowOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk4 min

Playwright Retries: How to Keep a Record of Every Failure

Playwright retries can help diagnose intermittent failures, but a retry pass should not erase the initial error. Learn how to configure attempts, capture artifacts, and report each result.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Playwright Test lets you set a retry budget—the maximum number of additional attempts after a test fails—but a later passing attempt does not erase the original failure. To understand what happened, preserve evidence for each attempt and report both the final classification and the initial error. Playwright provides retries, test metadata, artifacts, and reporter hooks; a “failure receipt” is a useful reporting pattern, not a built-in Playwright feature.

What a Playwright retry budget means

Retries are attempts made after the initial run. Playwright Test defaults to zero retries; setting retries configures the maximum number of additional attempts. For example, retries: 2 permits one initial attempt plus up to two retries. You can configure retries in the Playwright config or scope them to a describe group or file. See the official retry documentation and TestConfig API.

As an Amazon Associate I earn from qualifying purchases.

import { defineConfig } from '@playwright/test';

export default defineConfig({
  retries: 2,
});

A budget is a ceiling, not a target: tests that pass do not consume retries. A higher value may help expose intermittent behavior, but it also allows a failing test to take more attempts before the run finishes. Choose a limit that suits your CI time budget and the value of collecting another diagnostic attempt; do not treat retries as a fix for the underlying failure.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

How Playwright classifies the result

Playwright reports tests as passed, flaky, or failed. A test that passes on its first attempt is passed. A test that fails and then passes on a retry is flaky. A test that continues to fail through its available retries is failed. The retry outcome is useful information, but a flaky result still means the initial attempt failed and should remain visible in diagnostics. The classification rules are described in the Playwright retry documentation.

How to identify and preserve each attempt

Use the retry index

testInfo.retry is 0 for the initial attempt and increases for each subsequent retry. Use it to label attempt-specific setup or evidence. It does not by itself capture or retain artifacts. TestInfo also exposes status information and methods for adding attachments.

test('loads the account page', async ({ page }, testInfo) => {
  console.log(`Attempt ${testInfo.retry}`);
  // Test steps...
});

Account for worker restarts

When a test fails, Playwright Test discards the worker process and browser, then starts a new worker for a retry. A retry can therefore run with a fresh worker and browser context. That does not necessarily reset external state: a test account, remote service, or other shared resource may still need explicit cleanup or retry-safe setup. Use testInfo.retry when a setup action genuinely needs to vary by attempt, without suppressing or converting the initial failure.

Choose artifact modes to match the evidence you need

Trace, screenshot, and video capture are configured separately. Trace modes include off, on, retain-on-failure, retain-on-first-failure, retain-on-failure-and-retries, on-first-retry, and on-all-retries. Screenshot settings can be off, always on, or failure-only; video has its own capture and retention settings. Consult the current configuration options and Trace Viewer guide, and check that the options are supported by the Playwright version installed in your project.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

on-first-retry is useful when the goal is to inspect a retry, but it does not record the original failed attempt. If retries are disabled, a retry-only trace mode will not produce a trace. When the original failure matters, choose a mode that captures and retains evidence for the first failed run, or make the missing evidence explicit in the report. Do not claim that every attempt has a trace unless the configured mode actually records it and the file survives retention.

Choose capture settings by weighing four factors:

  • Which attempts must be recorded: the initial run, retries, or both.
  • Which recorded files will be retained after the run.
  • The storage and runtime overhead of capturing artifacts.
  • Whether the investigation needs the original failure, later retry behavior, or both.

Trace Viewer provides a GUI for examining recorded traces and replaying the action context. A trace is useful only if it was captured and retained for the attempt in question.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

What to put in a failure receipt

Playwright does not define a built-in object called a failure receipt. Treat it as a small per-attempt reporting record assembled from test results, TestInfo, and artifact references. A custom reporter can process test lifecycle events; for example, its onTestEnd hook can centralize reporting. The Reporter API and TestInfo API document the supported surfaces.

A practical receipt should retain:

  • Stable test identity, plus project and environment context.
  • Attempt number from testInfo.retry, attempt outcome or status, and elapsed time where available.
  • The error or assertion message and relevant test or worker output.
  • Filenames or links to screenshots, videos, and traces that were actually retained for that attempt.
  • The final test classification—passed, flaky, or failed—without dropping evidence from an earlier failed attempt.

Keep artifact references attached to the attempt that produced them. If a retry passes after the initial failure, the final result can say “flaky” while the receipt still points to the initial error and its retained artifacts. A reporter should not imply that an artifact exists when the selected capture or retention mode did not produce it.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

How to choose a retry and evidence policy

  1. Set a bounded retry count. Configure retries at the broadest scope that fits the suite, then narrow it only where particular tests need a different policy.
  2. Decide which attempt matters diagnostically. If the original failure is the key signal, configure capture and retention for that failed run. If you also need to see how a retry behaves, select a mode that records retries too.
  3. Record attempt identity and outcome. Use testInfo.retry and supported test result data so that initial and later attempts cannot be confused.
  4. Report the final classification alongside attempt evidence. A retry pass should be reported as flaky, not as an unqualified clean pass that hides the failed attempt.
  5. Verify files and version support. Confirm that the configured mode is supported by the installed Playwright version and that the output pipeline retains and links the artifacts your receipt names.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.