Professional Documents
Culture Documents
Guide on Configuring Various Timeouts in Playwright
Guide on Configuring Various Timeouts in Playwright
1. Test Timeout
Description: This is the maximum time allowed for a single test to run. It includes the
execution time of the test function, beforeEach, afterEach, beforeAll, and afterAll hooks, and
any fixtures used by the test.
Default: 30 seconds
// playwright.config.ts
import { defineConfig } from '@playwright/test';
2. Expect Timeout
Description: This timeout applies to assertions made using Playwright's expect function. It
defines how long Playwright will wait for a condition to be met before throwing an error.
Default: 5 seconds
// playwright.config.ts
import { defineConfig } from '@playwright/test';
3. Global Timeout
Description: This is the maximum time allowed for the entire test suite to run. It's useful for
preventing excessive resource usage when something goes wrong during the test run.
Set in Configuration:
// playwright.config.ts
import { defineConfig } from '@playwright/test';
4. Action Timeout
Description: This timeout applies to individual actions such as clicks, type operations, and
other interactions with the page.
// playwright.config.ts
import { defineConfig } from '@playwright/test';
5. Navigation Timeout
// playwright.config.ts
import { defineConfig } from '@playwright/test';
Override in Hooks:
7. Fixture Timeout
Description: Fixtures are pieces of setup code that can be shared across multiple tests. This
timeout applies to individual fixtures, which can have their own timeout that is separate from
the test timeout.
Set in Fixture:
// playwright.config.ts
import { defineConfig } from '@playwright/test';
Examples in Tests
By understanding and utilizing these configurations, you can fine-tune the performance and
reliability of your Playwright tests, ensuring they run efficiently and effectively.