Use Playwright test.describe.configure for serial tests
Run a group of dependent Playwright tests in order in one worker with test.describe.configure and mode serial, and retry them together.
Playwright runs tests in parallel and isolates them, which is right until a flow genuinely depends on the previous step, such as create, edit, delete. Mark that group as serial.
import { test, expect } from '@playwright/test';
test.describe.configure({ mode: 'serial' });
let page;
test.beforeAll(async ({ browser }) => {
page = await browser.newPage();
});
test.afterAll(async () => {
await page.close();
});
test('creates a draft', async () => {
await page.goto('http://localhost:3000/new');
await page.getByLabel('Title').fill('Hello');
await page.getByRole('button', { name: 'Save draft' }).click();
await expect(page.getByText('Draft saved')).toBeVisible();
});
test('publishes the draft', async () => {
await page.getByRole('button', { name: 'Publish' }).click();
await expect(page.getByText('Published')).toBeVisible();
});Running 2 tests using 1 worker
✓ 1 article-lifecycle.spec.js:15:5 › creates a draft
✓ 2 article-lifecycle.spec.js:22:5 › publishes the draft
2 passedIn serial mode the tests of the group run in order in one worker. If one fails, the rest are skipped, and on a retry the whole group starts again from the first test, as the Playwright docs explain.
The Playwright team recommends independent tests instead. Prefer one test with several steps, or fixtures that create the state, and keep serial mode for flows you cannot split.