How to Set Time Budgets and Timeouts for E2E Tests in GitHub Actions
Layer three timeouts: a job timeout to cap the run, a per-test timeout, and an expect timeout for assertions.
Set timeout-minutes on the job so a stuck browser is killed, and set timeout plus expect.timeout in the Playwright config so individual tests and waits fail quickly rather than hanging.
playwright.config.ts
playwright.config.ts
import { defineConfig } from '@playwright/test'
export default defineConfig({
timeout: 30_000,
expect: { timeout: 5_000 },
use: { actionTimeout: 10_000, navigationTimeout: 15_000 },
})Workflow
.github/workflows/ci.yml
jobs:
e2e:
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: actions/checkout@v4
- run: npm ci
- run: npx playwright install --with-deps
- run: npx playwright testGotchas
- Without a job
timeout-minutes, a hung E2E run can consume up to the 360-minute ceiling. - Set the per-test timeout above the slowest legitimate test, not the average, to avoid false failures.
Related guides
How to Retry Flaky E2E Tests in GitHub ActionsReduce flaky E2E failures in GitHub Actions by enabling framework-level retries in Playwright or Cypress so a…
How to Tune Playwright Workers and Parallelism in GitHub ActionsControl Playwright parallelism in GitHub Actions with the workers setting, balancing local files against the…