Playwright Test stops a test when its configured timeout expires, which keeps stuck browser checks from tying up local runs or CI jobs. Setting a project-level timeout gives slower legitimate flows enough room without letting a broken test run unchecked.
The timeout option belongs at the top level of playwright.config.ts or playwright.config.js. It is measured in milliseconds and covers the test function, test-scoped fixtures, and beforeEach hooks; assertion, action, navigation, and whole-run timeouts use separate settings.
Use a value that matches the slowest expected user flow in the suite. If only one spec needs more time, keep the project default lower and use test.setTimeout() or test.slow() inside that spec instead of raising the limit for every test.
Related: How to run Playwright tests
Related: How to debug Playwright tests
import { defineConfig } from '@playwright/test';
export default defineConfig({
timeout: 5_000,
testDir: './tests',
});
Replace 5_000 with the project limit in milliseconds. The short value keeps the verification probe quick.
$ npx playwright test --list Listing tests: home.spec.ts:3:5 › home page shows ready state Total: 1 test in 1 file
$ npx playwright test Running 1 test using 1 worker ✓ 1 tests/home.spec.ts:3:5 › home page shows ready state (33ms) 1 passed (485ms)
import { test } from '@playwright/test';
test('slow operation exceeds timeout', async () => {
await new Promise(resolve => setTimeout(resolve, 6_000));
});
If the configured timeout is higher than 5_000, make the sleep value longer than that timeout before running the probe.
$ npx playwright test tests/slow-timeout.spec.ts
Running 1 test using 1 worker
✘ 1 tests/slow-timeout.spec.ts:3:5 › slow operation exceeds timeout (5.0s)
##### snipped #####
Test timeout of 5000ms exceeded.
1 failed
tests/slow-timeout.spec.ts:3:5 › slow operation exceeds timeout
The failure is expected when the probe sleeps longer than the configured timeout.
$ rm tests/slow-timeout.spec.ts