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

Set Playwright Test’s retries option to the number of extra attempts allowed for each failed test. The default is 0. A useful starting point is retries: process.env.CI ? 2 : 0, which retries failures in CI but leaves local runs unchanged. A test that fails and then passes is reported as flaky; use the retry to collect evidence and investigate, not to treat the failure as fixed.

Configure retries in Playwright Test

Retries are a test-runner setting, not part of the use options for browser contexts. Set retries at the top level of the Playwright configuration to apply it across projects, or set it on an individual project when only that project needs retries.

Set a CI-only retry count

In playwright.config.ts, the following configuration allows up to two additional attempts for a failed test when the CI environment variable is set. Without that variable, it performs no retries. It also records a trace on the first retry, which can help explain why the initial attempt failed.

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

export default defineConfig({
  retries: process.env.CI ? 2 : 0,
  use: {
    trace: 'on-first-retry',
  },
});

The CI check is an example policy, not a Playwright requirement. Make sure your CI provider actually sets CI; otherwise this expression evaluates to zero retries. The configured number is a maximum of extra attempts, not a guaranteed number of runs. A test that passes on its first attempt does not need retries.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter
  • Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
  • Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
  • Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
  • Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
  • 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.

Scope retries to a project

If projects have different stability or runtime needs, use a project-level value rather than increasing retries for the entire suite. For example, a browser project can have its own retry count while other projects inherit the top-level value:

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

export default defineConfig({
  retries: process.env.CI ? 1 : 0,
  projects: [
    {
      name: 'chromium',
      retries: process.env.CI ? 2 : 0,
      use: { browserName: 'chromium' },
    },
    {
      name: 'firefox',
      use: { browserName: 'firefox' },
    },
  ],
});

Here Chromium overrides the top-level retry count. Firefox has no project-specific value, so it uses the top-level setting. Adjust the project names and browser configuration to match your suite.

Override the count for one run

Use the CLI when you need a temporary run-specific value without editing configuration:

npx playwright test --retries=2

The CLI option is --retries <retries>. It sets the maximum additional attempts for that run and can be useful when reproducing a CI-only failure locally. Keep the committed configuration as the team’s normal policy rather than relying on an individual command-line override.

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.
Rank #2
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter
  • 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
  • 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
  • Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
  • 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
  • What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.

Choose a retry count deliberately

Retries trade faster feedback for more execution time and more chances to observe intermittent failures. If the suite runs in parallel, retries also consume worker capacity. Set the count based on how much time the team can spend waiting and how valuable it is to identify intermittent failures in the run that detects them.

  • Zero retries: gives the simplest signal and avoids extending runs. This is the documented default and a reasonable local setting while debugging.
  • One or two retries in CI: can expose intermittent behavior and provide another attempt to collect diagnostics. Playwright’s configuration documentation uses two retries as an example for CI; it is not a universal recommendation.
  • More retries: can make a run substantially longer when failures recur. A high count may also make instability easier to overlook if the final result is treated as success.

Do not interpret a green run after retries as proof that the test or application is reliable. The first failure still matters. Track flaky outcomes and fix their causes, such as nondeterministic test setup or dependencies, rather than continually increasing the retry count.

Understand flaky outcomes and retry scheduling

Playwright classifies a test that fails initially but passes on a retry as flaky. A test that continues to fail after its retries remains failed. If you want a flaky result to fail the run instead of being accepted as a passing result, enable failOnFlakyTests in the configuration or use --fail-on-flaky-tests on the command line. Check that these options are available in the Playwright version installed by your project.

Immediate versus isolated retries

The current TestConfig API reference documents retryStrategy, introduced in Playwright v1.62. Its default, immediate, schedules a failed test’s retry when a worker is available, interleaved with the rest of the run. isolated waits until other tests have finished, then runs retries one at a time in a single worker. That can reduce interference between tests, but may make the run take longer.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Sale
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter
  • Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
  • Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
  • Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
  • Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
  • What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.
import { defineConfig } from '@playwright/test';

export default defineConfig({
  retries: process.env.CI ? 2 : 0,
  retryStrategy: 'isolated',
});

Use retryStrategy only if the installed version supports it; it is not a replacement for choosing a retry count. If the option is rejected as unknown, check the project’s Playwright version before changing the test logic.

Capture evidence from the failed attempt

A retry is most useful when it leaves evidence that can distinguish a timing issue, a failed network request, and a genuine application defect. For CI, Playwright recommends trace: 'on-first-retry'. This records a trace.zip for the first retry. Open it in Trace Viewer or from the HTML report to examine the action timeline, DOM snapshots, and network requests.

Pick a trace mode for the question you need to answer

  • on-first-retry records the first retry, a practical CI choice when you want targeted diagnostic artifacts.
  • on-all-retries records each retry when comparing repeated attempts matters.
  • retain-on-failure retains trace evidence for a test that fails.
  • retain-on-failure-and-retries retains evidence for the failure and retries.

These modes differ in which attempts produce retained traces. Choose based on the failure you are investigating and the amount of artifact storage and transfer your CI run can support. Playwright cautions that tracing every run is performance-heavy. For a local investigation where you want a trace for each test, run:

npx playwright test --trace on

A trace lets you inspect what happened during execution; it does not diagnose the root cause automatically or repair the test. Compare the first failure with the retry, especially the actions immediately before the failure and their associated DOM or network evidence.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #4
Sale
UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray
  • Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
  • Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
  • Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
  • Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
  • Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft

Run retries reliably in CI

Retries do not change how Playwright or its browsers must be installed. The Playwright CI guide’s basic sequence is to install the project packages, install the browser binaries and system dependencies, and then run the test suite:

npm ci
npx playwright install --with-deps
npx playwright test

Use the package-install command that matches your package manager and lockfile. For CI stability and reproducibility, Playwright recommends starting with one worker. Self-hosted systems may instead run tests in parallel or use sharding, depending on their resources and setup. Worker count is a separate setting from retries: retries determine how many additional attempts are allowed after failure, while worker count determines how many tests can run concurrently.

For a CI pipeline, confirm that the job installs the browser binaries and dependencies needed by the project, uses the intended retry configuration, and retains the report or trace artifacts you need after the job ends. A retry can collect a trace, but that trace is of little use if the pipeline discards it.

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

Troubleshoot retry behavior

Failed tests are not retried

  • Check that retries is set in the top-level configuration or the relevant project configuration, not inside use.
  • Check whether a project-level value overrides the top-level value.
  • If you rely on process.env.CI, verify that the environment variable is set in the job. Otherwise the example expression selects zero.
  • Use npx playwright test --retries=2 once to check whether a command-line setting produces the expected behavior.

The test passes on retry, but the run is still marked flaky

That is the expected classification for an initial failure followed by a passing retry. Review the original attempt’s trace and compare it with the retry. If the team wants flaky outcomes to fail the run, use failOnFlakyTests or --fail-on-flaky-tests where supported by the installed version.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Best Value
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display
  • 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
  • Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
  • Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
  • HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
  • What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.

The run takes much longer than expected

Retries add attempts only for tests that fail, but repeated failures can lengthen a run substantially. Reduce the retry count if the extra runtime is not worth the diagnostic value. Also review worker count and whether an isolated retry strategy is appropriate: isolated retries are serialized after other tests and can increase elapsed time.

A trace is missing or too expensive to retain

Confirm that the chosen trace mode records the attempt you are examining and that the CI system saves the resulting artifacts. Use on-first-retry for a narrower diagnostic footprint instead of tracing every run; use a broader mode only when the additional evidence is necessary.

retryStrategy or flaky-test options are rejected

Configuration APIs change across Playwright releases. Check the installed package version and use the API reference that matches it. The documented retryStrategy option requires v1.62 or later; an older installation will not accept it.

Or skip the browser setup

ScreenshotNeo is a website screenshot API, not a Playwright Test runner: it does not retry test assertions or replace your suite. If what you need is a website capture rather than an automated browser test, one request can return an image or PDF without configuring Playwright locally. Its capture flow can remove cookie banners, newsletter popups, and chat widgets before the shot; bot checks, blank pages, and failed loads are not billed; and an MCP server lets AI agents take screenshots. The free plan includes 1,000 screenshots a month with no card, and paid plans start at $5 for 3,000.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
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 request options. To start with the free plan, sign up for ScreenshotNeo.

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.