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
Steps to set Playwright test timeout:
- Open playwright.config.ts in the Playwright project root.
- Set timeout as a top-level config option.
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.
- List the tests collected by the updated configuration.
$ npx playwright test --list Listing tests: home.spec.ts:3:5 › home page shows ready state Total: 1 test in 1 file
- Run the suite with the new timeout setting.
$ 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)
- Create a temporary slow test at tests/slow-timeout.spec.ts.
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.
- Run the temporary slow test.
$ 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 timeoutThe failure is expected when the probe sleeps longer than the configured timeout.
- Remove the temporary timeout probe.
$ rm tests/slow-timeout.spec.ts
Mohd Shakir Zakaria is a cloud architect with deep roots in software development and open-source advocacy. Certified in AWS, Red Hat, VMware, ITIL, and Linux, he specializes in designing and managing robust cloud and on-premises infrastructures.