playwright test timeout 30000ms exceeded: how to fix
Fixes Playwright's 30s test timeout: slow steps, missing waits, and config. Use when a Playwright test fails with 'Timeout of 30000ms exceeded'. Not for expect assertion timeouts (5s default, different knob).
TL;DR
The test took longer than 30 seconds. Find which step was slow with the trace, make the test wait on the right condition instead of wall-clock time, and only raise the timeout for genuinely slow flows.
Error
Error: Test timeout of 30000ms exceeded.Steps
- Open the trace (
npx playwright show-trace trace.zip) and find the longest step. Expected: one step dominates the 30s. - If the slow step is a navigation or API call the app needs, wait on it explicitly:
await page.waitForResponse('**/api/items'). Expected: the test tracks completion, not time. - If the step is an assertion polling slowly, raise the expect timeout for that line:
await expect(page.getByText('Saved')).toBeVisible({ timeout: 15000 }). Expected: slow-but-correct assertions pass. - If the whole flow is legitimately slow (large file processing), raise the test timeout:
test.setTimeout(90000). Expected: the slow test gets room without affecting others. - Re-run with
--repeat-each=3. Expected: three greens before calling it fixed.
When to use
- The error is exactly
Test timeout of Xms exceeded. - The trace shows one slow step, not many medium ones.
When not to use
expecttimeouts of 5000ms (raise the expect timeout, not the test timeout).- Every test is slow (suite-level performance problem; see speedup skill).
Tool compatibility
- Playwright 1.30 through latest;
test.setTimeout, per-assertion{ timeout }.
Variant phrasings
Test timeout of 60000ms exceeded
Same pattern with a custom timeout; diagnose the slow step the same way.
Playwright test timed out after 30s
Identical error in different words.
Why it happens
Playwright kills tests that run too long to keep CI moving. The usual causes are waiting on the wrong condition, a hanging backend call, or a flow that is simply slow.
Edge cases
test.setTimeout(0)disables the timeout; useful for debugging, dangerous in CI.- Timeouts inside
test.beforeEachhooks count against the test; slow setup looks like a slow test. page.waitForTimeout()(fixed sleeps) is the most common cause; replace with event-based waits.
Provenance
Resolved from the public thread: https://vectle.com/posts/pst_hWRoxE8CXDEKyk-NjZXsRg
Maintainer review
No maintainer verification is recorded for this version.
This records the version a maintainer checked. It does not assert that the version is the latest upstream release.