|Test timeout|30000 ms|Timeout for each test, includes test, hooks and fixtures:<br/><spanstyle={{textTransform:'uppercase',fontSize:'smaller',fontWeight:'bold',opacity:'0.6'}}>Set default</span><br/><code>{`config = { timeout: 60000 }`}</code><br/><spanstyle={{textTransform:'uppercase',fontSize:'smaller',fontWeight:'bold',opacity:'0.6'}}>Override</span><br/><code>{`test.setTimeout(120000)`}`</code> |
|Expect timeout|5000 ms|Timeout for each assertion:<br/><spanstyle={{textTransform:'uppercase',fontSize:'smaller',fontWeight:'bold',opacity:'0.6'}}>Set default</span><br/><code>{`config = { expect: { timeout: 10000 } }`}</code><br/><spanstyle={{textTransform:'uppercase',fontSize:'smaller',fontWeight:'bold',opacity:'0.6'}}>Override</span><br/><code>{`expect(locator).toBeVisible({ timeout: 10000 })`}</code> |
|Action timeout| no timeout |Timeout for each action:<br/><spanstyle={{textTransform:'uppercase',fontSize:'smaller',fontWeight:'bold',opacity:'0.6'}}>Set default</span><br/><code>{`config = { use: { actionTimeout: 10000 } }`}</code><br/><spanstyle={{textTransform:'uppercase',fontSize:'smaller',fontWeight:'bold',opacity:'0.6'}}>Override</span><br/><code>{`locator.click({ timeout: 10000 })`}</code>|
|Navigation timeout| no timeout |Timeout for each navigation action:<br/><spanstyle={{textTransform:'uppercase',fontSize:'smaller',fontWeight:'bold',opacity:'0.6'}}>Set default</span><br/><code>{`config = { use: { navigationTimeout: 30000 } }`}</code><br/><spanstyle={{textTransform:'uppercase',fontSize:'smaller',fontWeight:'bold',opacity:'0.6'}}>Override</span><br/><code>{`page.goto('/', { timeout: 30000 })`}</code>|
|Global timeout|no timeout |Global timeout for the whole test run:<br/><spanstyle={{textTransform:'uppercase',fontSize:'smaller',fontWeight:'bold',opacity:'0.6'}}>Set in config</span><br/><code>{`config = { globalTimeout: 60*60*1000 }`}</code><br/>|
Playwright Test enforces a timeout for each test, 30 seconds by default. Time spent by the test function, fixtures, `beforeEach` and `afterEach` hooks is included in the test timeout.
Timed out test produces the following error:
```
example.spec.ts:3:1 › basic test ===========================
Timeout of 30000ms exceeded.
```
The same test timeout also applies to `beforeAll` and `afterAll` hooks.
// Extend timeout for all tests running this hook by 30 seconds.
testInfo.setTimeout(testInfo.timeout + 30000);
});
```
```js js-flavor=ts
import { test, expect } from '@playwright/test';
test.beforeEach(async ({ page }, testInfo) => {
// Extend timeout for all tests running this hook by 30 seconds.
testInfo.setTimeout(testInfo.timeout + 30000);
});
```
API reference: [`method: TestInfo.setTimeout`].
## Expect timeout
Web-first assertions like `expect(locator).toHaveText()` have a separate timeout, 5 seconds by default. Assertion timeout is unrelated to the test timeout. It produces the following error:
```
example.spec.ts:3:1 › basic test ===========================
Test usually performs some actions by calling Playwright APIs, for example `locator.click()`. These actions do not have a timeout by default, but you can set one. Action that timed out produces the following error:
```
example.spec.ts:3:1 › basic test ===========================
Playwright Test supports a timeout for the whole test run. This prevents excess resource usage when everything went wrong. There is no default global timeout, but you can set a reasonable one in the config, for example one hour. Global timeout produces the following error: