Rayrun

How do I configure retries for specific tests in Playwright?

Answer

To configure retries for specific tests in Playwright, you can use test.describe.configure() within a test.describe() block. This allows you to set the number of retries for a group of tests or a single file.

Here's an example:

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

test.describe('retry specific tests', () => {
  // All tests in this describe group will get 2 retry attempts.
  test.describe.configure({ retries: 2 });

  test('test 1', async ({ page }) => {
    await page.goto('https://ray.run/');
    // ...
  });

  test('test 2', async ({ page }) => {
    await page.goto('https://ray.run/');
    // ...
  });
});

In this example, both test 1 and test 2 will have 2 retry attempts if they fail.

If you have dependent tests that need to be run together and in order, use test.describe.serial(). This ensures that all dependent tests will be retried together if any of them fail.

Thank you!
Was this helpful?
Still have questions?

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

TwitterGitHubLinkedIn
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.