How to set Playwright test timeout

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.

Steps to set Playwright test timeout:

  1. Open playwright.config.ts in the Playwright project root.
  2. 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.

  3. 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
  4. 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)
  5. 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.

  6. 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 timeout

    The failure is expected when the probe sleeps longer than the configured timeout.

  7. Remove the temporary timeout probe.
    $ rm tests/slow-timeout.spec.ts