What is the process for configuring retries in Playwright Test?


To configure retries in Playwright Test, you have several options. You can use the command line, update the configuration file, or specify retries for specific test groups.

Command Line

Run your tests with the --retries flag, like this:

npx playwright test --retries=3

This command retries failing tests 3 times before marking them as failed.

Configuration File

Add the retries property to your playwright.config.ts file:

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

const config: PlaywrightTestConfig = {
  retries: 3,
  // ...

export default config;

Specific Test Groups

Use test.describe.configure() to set retries for a group of tests:

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

test.describe(() => {
  test.describe.configure({ retries: 2 });

  test('test 1', async ({ page }) => {
    // ...

  test('test 2', async ({ page }) => {
    // ...

Detect Retries at Runtime

Access testInfo.retry to detect retries and perform actions like clearing server-side caches:

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

test('my test', async ({ page }, testInfo) => {
  if (testInfo.retry) await cleanSomeCachesOnTheServer();
  // ...

These methods allow you to configure and handle retries in Playwright Test according to your needs.

Thank you!
Was this helpful?
Still have questions?

If you still have questions, please ask a question and I will try to answer it.

AboutQuestionsDiscord ForumBrowser ExtensionTagsQA Jobs

Rayrun is a community for QA engineers. I am constantly looking for new ways to add value to people learning Playwright and other browser automation frameworks. If you have feedback, email luc@ray.run.