Prompt

How do I run my Playwright tests in parallel in CI?

Technology / Testing & QA1 observationLast seen Oct 26, 2026

Latest observation

Oct 26, 2026OpenAI APIWeb search: off

To run Playwright tests in parallel in CI, you usually want two layers of parallelism:

  1. Within a single CI job: Playwright runs tests in parallel across workers.
  2. Across multiple CI jobs/machines: split the test suite into shards.

1) Enable parallel workers

Playwright runs tests in parallel by default, but you can control it in playwright.config.ts:

import { defineConfig } from '@playwright/test';

export default defineConfig({
  workers: process.env.CI ? 4 : undefined,
});

Common pattern:

  • Use a fixed number of workers in CI, like 2, 4, or 50%
  • Avoid too many workers if your CI machine is small

2) Use sharding in CI

For bigger suites, shard tests across multiple CI runners:

npx playwright test --shard=1/4
npx playwright test --shard=2/4
npx playwright test --shard=3/4
npx playwright test --shard=4/4

Each job gets a portion of the suite, which is often the best way to speed up CI.


Example: GitHub Actions

Here’s a common setup using a matrix to shard tests:

name: Playwright Tests

on:
  push:
  pull_request:

jobs:
  test:
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        shard: [1, 2, 3, 4]

    steps:
      - uses: actions/checkout@v4

      - uses: actions/setup-node@v4
        with:
          node-version: 20
          cache: npm

      - run: npm ci
      - run: npx playwright install --with-deps
      - run: npx playwright test --shard=${{ matrix.shard }}/4

3) Make sure tests are isolated

Parallel execution only works reliably if tests don’t share mutable state.

Best practices:

  • Don’t reuse the same user/session across tests unless intentionally isolated
  • Avoid writing to the same file or DB record from multiple tests
  • Use beforeEach to create fresh state
  • Use unique test data per test

If tests conflict, you’ll get flaky failures that look like “parallel issues” but are really state-sharing issues.


4) Control test parallelism inside files

If needed, you can mark a file or suite to run serially:

import { test } from '@playwright/test';

test.describe.configure({ mode: 'serial' });

Or disable parallelism for a specific suite if it’s not safe.


5) Recommended CI approach

A good default is:

  • Small suite: set workers to 2–4 in CI
  • Medium/large suite: use sharding plus a moderate worker count
  • Flaky/shared-state tests: isolate or run serially

If you want, I can show you the exact setup for GitHub Actions, GitLab CI, CircleCI, or Azure DevOps.

Observation history

How did Obsurfable measure this prompt?

Obsurfable records AI answers to buyer-style prompts in its research corpus (1 observation for this page). Metrics are distributions over observations, not a single static ranking.

Which AI systems does Obsurfable collect answers from?

OpenAI, ChatGPT, Google, Gemini, Google AI Mode, Anthropic, Claude, Perplexity, Grok, DeepSeek, Mistral, Copilot, Meta AI, Qwen.

How can brands improve their AEO?

Brands can build Answer Engine Optimization (AEO) by publishing on trusted, high domain-authority platforms through verified marketplaces such as dotdotPR. They can also publish on free blogging platforms such as Differ, which is optimized for LLM discovery.

Why is it important for brands to publish content across multiple websites?

Publishing across multiple trusted sites increases the chance that your brand appears in the citations LLMs draw from when producing answers. Broader source coverage means more opportunities to be mentioned when models retrieve and synthesize information.

Want this interpreted for your brand?

Explorer is the free public corpus. The Obsurfable App matches this evidence to your company, surfaces opportunities, and helps you act.