Case study 03
Cutting regression from over 60 minutes to under 20
How making tests independent of each other unlocked parallel execution and cut web regression time by more than two thirds while coverage kept growing.
Playwright · TypeScript · GitHub Actions · API seeding
- 60+ → <20
- minutes per regression run
- >66%
- faster feedback
- 2.5×
- coverage over the same period
The problem
A full web regression took more than an hour. Engineers stopped waiting for it, so it ran less often and caught problems later. Simply adding workers made things worse: tests shared accounts and records, so running them in parallel produced random failures.
The bottleneck was shared test data, not machine capacity.
What I did
1.Measure before optimising
I ranked specs by duration and failure rate from CI reports. A small number of long serial flows and UI-driven setup steps accounted for most of the runtime.
2.Worker-scoped isolation
Each Playwright worker gets its own account and workspace, created once through the API and reused by every test on that worker. Tests on different workers can't touch each other's data, so parallelism becomes safe.
fixtures/workspace.ts import { test as base } from "@playwright/test"; import { ApiClient } from "../api/client"; type WorkerFixtures = { workspace: { id: string; token: string } }; export const test = base.extend<{}, WorkerFixtures>({ workspace: [ async ({ playwright }, use, workerInfo) => { const api = new ApiClient(await playwright.request.newContext()); const ws = await api.createWorkspace(`w${workerInfo.workerIndex}-${Date.now()}`); try { await use(ws); } finally { await api.deleteWorkspace(ws.id); } }, { scope: "worker" }, ], });3.Log in once, not once per test
Authentication runs in a setup project and saves storage state. Every test starts already signed in, instead of repeating the login flow in each test.
playwright.config.ts import { defineConfig } from "@playwright/test"; export default defineConfig({ fullyParallel: true, workers: process.env.CI ? 4 : undefined, retries: process.env.CI ? 1 : 0, reporter: [["html"], ["github"]], projects: [ { name: "setup", testMatch: /auth\.setup\.ts/ }, { name: "chromium", dependencies: ["setup"], use: { storageState: ".auth/user.json" }, }, ], });4.Shard in CI
With isolation in place, the suite splits across CI machines with a matrix. Each shard finishes in minutes and the reports merge into one.
.github/workflows/regression.yml jobs: e2e: strategy: fail-fast: false matrix: shard: [1, 2, 3, 4] runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: { node-version: 22, cache: npm } - run: npm ci && npx playwright install --with-deps chromium - run: npx playwright test --shard=${{ matrix.shard }}/4 - uses: actions/upload-artifact@v4 if: always() with: { name: blob-${{ matrix.shard }}, path: blob-report }5.Treat flakiness as a defect
Retries are capped at one and every retried test gets tracked. Replacing fixed waits with web-first assertions and reusable wait utilities reduced flakiness significantly.
Outcome
- Regression dropped from over 60 minutes to under 20, short enough to run on every merge.
- Coverage kept growing (2.5× overall) without runtime creeping back up, because new tests inherit isolation by default.
- Engineers wait for the result again, so problems are caught on the pull request that caused them.
Lessons learned
- Parallelism is a data-design problem before it's an infrastructure problem.
- Engineers only act on a suite they trust, so reliability and speed matter as much as coverage.
Code samples are original demonstrations written for this site. They show the pattern, not any employer’s implementation.
Next case studyBuilding an AI test case generator with human approval →