Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix Now×
Skip to content
World desk4 min

How to Retry Failed Visual Regression Tests with Playwright

Set Playwright Test retries without mistaking a flaky pass for a stable visual regression test. Includes CI, trace, and screenshot workflow guidance.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To retry failed visual regression tests in Playwright Test, set a retry count in playwright.config.ts or pass --retries=N to the test command. Retries are additional attempts after the initial run. A test that fails and then passes is reported as flaky, not as a clean, stable pass—use that result to investigate instability rather than to approve a visual change.

Configure retries in Playwright Test

Playwright Test does not retry failed tests by default. Add a retry count to the project configuration:

As an Amazon Associate I earn from qualifying purchases.

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

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

Here, retries: 2 means the initial attempt plus up to two retries. You can set retries for a particular run from the command line instead:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
npx playwright test --retries=2

Use the Playwright Test retry documentation to confirm the configuration supported by the version installed in your project. The option set can change across versions.

Understand what a retry result means

Playwright classifies a test that fails on its first attempt and passes on a retry as flaky. A test that fails on the initial attempt and every retry remains failed. After a test failure, Playwright discards that worker process and starts a replacement; configured retries run in the replacement worker.

A retry can help a run continue despite a transient failure, but it does not show that the test or application is reliable. Track flaky outcomes and investigate their causes. If your CI policy should reject any run containing a flaky test, Playwright provides failOnFlakyTests and a corresponding CLI option; check the documentation for the version in use before enabling it. See Playwright’s retry and flaky-test guidance.

Choose how retries are scheduled

In versions that support retryStrategy, Playwright documents two choices. Verify availability in your installed version before adding this option.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Strategy How it runs Trade-off
immediate A failed test is retried as soon as a worker is available; retries can interleave with the rest of the run. Provides a retry sooner, but concurrent test activity may contribute to interference.
isolated Retries run at the end of the test run, one by one in a single worker. Reduces interference from other running tests, but can increase total run time.

These scheduling options are documented by Playwright. The right retry count and strategy depend on your suite and CI environment; the documentation does not prescribe a universally correct count.

Make visual comparisons reproducible

Retries are not a substitute for controlling screenshot inputs. Keep the operating system and browser versions consistent between baseline creation and test runs so that comparisons are made under reproducible conditions. Before treating a mismatch as flakiness, determine whether the expected UI or its approved baseline has intentionally changed.

For CI runs where stability and reproducibility take priority, Playwright recommends using one worker. Parallel workers or sharding can be appropriate when your CI infrastructure supports them, but they can also change execution conditions and resource contention. Select the approach that fits the environment in which the screenshots are captured. See Playwright’s CI guidance.

Keep evidence and make flaky results visible

Configure traces on the first retry so you can inspect what happened during a failed attempt. A trace can help distinguish an intermittent page or interaction problem from a mismatch caused by the screenshot environment. Playwright documents this approach in its retry guidance.

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

Choose an explicit CI policy: report flaky tests for follow-up, or fail the run when any test is flaky. The latter prevents retries from turning intermittent failures into an apparently healthy CI result. Retain the failure evidence your team needs to investigate, and avoid increasing retries simply to make a run appear green.

Separate test retries from visual-change approval

Playwright Test retries rerun a failed test. They do not approve a screenshot change or update a visual baseline. Visual-testing services may capture and compare snapshots and provide their own baseline review workflow; those are separate responsibilities.

For example, Chromatic documents a Playwright integration that captures page archives, uploads them to its cloud, and performs snapshot comparison. Its documentation also describes baseline review and CI checks. That comparison workflow is not the same thing as Playwright Test’s retry mechanism. See Chromatic’s Playwright integration documentation and Chromatic’s visual testing documentation.

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

Or skip the browser setup

If you need a screenshot rather than a Playwright-driven test run, ScreenshotNeo is a website screenshot API and MCP server. A single GET request returns an image or PDF, and its capture flow can accept cookie or consent banners and remove supported consent platforms, newsletter popups, and chat widgets before the shot.

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

For an API call, create a ScreenshotNeo account and use your API key. This cURL example saves a WebP screenshot of Stripe:

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

See the ScreenshotNeo API documentation for parameters and response details. Bot checks and CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed; response headers identify the page verdict and billing status. An MCP server provides take_screenshot, get_page_info, and capture_pdf tools for AI agents and MCP clients. The free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 screenshots.

Sign up for ScreenshotNeo’s free plan to try 1,000 screenshots a month with no card.

Frequently Asked Questions

Does Playwright retry a failed test automatically by default?

No. Retries are disabled unless you configure them or pass the --retries command-line option.

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

Does a passing retry mean the visual test is stable?

No. Playwright reports a test that failed and later passed as flaky; the initial failure remains a signal to investigate.

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 *

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.

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.