Playwright NotesRohit’s interview study guide
Chapter 12

Running in CI at Scale

How Playwright runs tests in parallel and keeps them isolated, how test locks protect a shared resource, how to split a suite across machines and merge the reports, a GitHub Actions workflow and the official Docker image, the reporters, and how to keep a big suite fast. Every test was run with Playwright 1.65.1 against the Practice Shop; the GitHub workflows pass actionlint but weren't run on GitHub.

7 topics
Parts marked Advanced are extra depth. Skip them on a first read or a quick revision.

#Workers and parallelism

Added

Playwright runs tests in worker processes: separate operating-system processes, each with its own browser. Workers never share memory, and each test still gets its own fresh browser context inside its worker. By default files run in parallel (one file per worker at a time) and tests inside a file run one after another, in order, in the same worker. fullyParallel: true (or --fully-parallel) lets the tests inside a file spread across workers too. The number of workers defaults to half your CPU cores; set it with workers in the config or --workers (a number or a percentage like "50%").

When a test fails, its worker is thrown away and a new one starts, so whatever state the failure left (a half-open dialog, a broken global) can't leak into the next test. That's also why beforeAll can run more than once in a suite: once per worker.

The mental model: checkout lanes at a supermarket. Each worker is a lane with its own till (browser). By default, each customer (file) goes through one lane with their whole basket (tests) in order. fullyParallel lets the items from one basket go through different lanes at once: faster, but only safe if no item depends on another.

This suite shows the difference. Each test does a little work for 2 seconds and records which worker ran it and when; a small script then summarises the run:

playwright.config.ts
import { defineConfig, devices } from "@playwright/test";

export default defineConfig({
  testDir: "./tests",
  workers: 4,
  use: { baseURL: "https://rohit-playwright.pages.dev" },
  projects: [{ name: "chromium", use: { ...devices["Desktop Chrome"] } }],
});
tests/timing.ts
import { writeFileSync } from "node:fs";
import type { Page, TestInfo } from "@playwright/test";

// Opens the shop, "works" for 2 s, and writes down which worker process ran this test and when.
export async function workAndRecord(page: Page, testInfo: TestInfo) {
  const start = Date.now();
  await page.goto("/practice/");
  await new Promise((r) => setTimeout(r, 2000));
  const record = { file: testInfo.file.split("/tests/")[1], worker: testInfo.workerIndex, start, end: Date.now() };
  writeFileSync(testInfo.outputPath("timing.json"), JSON.stringify(record));
}
tests/cart.spec.ts
import { test } from "@playwright/test";
import { workAndRecord } from "./timing";

test("cart test 1", async ({ page }, testInfo) => workAndRecord(page, testInfo));
test("cart test 2", async ({ page }, testInfo) => workAndRecord(page, testInfo));
tests/search.spec.ts
import { test } from "@playwright/test";
import { workAndRecord } from "./timing";

test("search test 1", async ({ page }, testInfo) => workAndRecord(page, testInfo));
test("search test 2", async ({ page }, testInfo) => workAndRecord(page, testInfo));
timeline.mjs
// Reads every test's timing.json and says, per file, how many worker processes ran its tests and whether they overlapped.
import { readdirSync, readFileSync, existsSync } from "node:fs";
const runs = readdirSync("test-results").filter((d) => existsSync(`test-results/${d}/timing.json`)).map((d) => JSON.parse(readFileSync(`test-results/${d}/timing.json`, "utf8")));
const overlap = (list) => list.some((a) => list.some((b) => a !== b && a.start < b.end && b.start < a.end));
for (const file of [...new Set(runs.map((r) => r.file))].sort()) {
  const tests = runs.filter((r) => r.file === file);
  const workers = new Set(tests.map((r) => r.worker)).size;
  console.log(`${file}: ${tests.length} tests, ${workers} worker process${workers > 1 ? "es" : ""}, ${overlap(tests) ? "at the same time" : "one after another"}`);
}
console.log(`the two files ran ${overlap([runs.filter((r) => r.file === "cart.spec.ts"), runs.filter((r) => r.file === "search.spec.ts")].map((t) => ({ start: Math.min(...t.map((r) => r.start)), end: Math.max(...t.map((r) => r.end)) }))) ? "at the same time" : "one after another"}`);
npx playwright test
Running 4 tests using 2 workers

  ✓  1 [chromium] › tests/cart.spec.ts:4:1 › cart test 1 (2.1s)
  ✓  2 [chromium] › tests/search.spec.ts:4:1 › search test 1 (2.1s)
  ✓  3 [chromium] › tests/cart.spec.ts:5:1 › cart test 2 (2.1s)
  ✓  4 [chromium] › tests/search.spec.ts:5:1 › search test 2 (2.1s)

  4 passed (4.6s)
node timeline.mjs
cart.spec.ts: 2 tests, 1 worker process, one after another
search.spec.ts: 2 tests, 1 worker process, one after another
the two files ran at the same time
npx playwright test --fully-parallel
Running 4 tests using 4 workers

  ✓  4 [chromium] › tests/cart.spec.ts:4:1 › cart test 1 (2.1s)
  ✓  2 [chromium] › tests/search.spec.ts:4:1 › search test 1 (2.1s)
  ✓  1 [chromium] › tests/cart.spec.ts:5:1 › cart test 2 (2.1s)
  ✓  3 [chromium] › tests/search.spec.ts:5:1 › search test 2 (2.1s)

  4 passed (2.7s)
node timeline.mjs
cart.spec.ts: 2 tests, 2 worker processes, at the same time
search.spec.ts: 2 tests, 2 worker processes, at the same time
the two files ran at the same time
What’s happening
  1. Default run. Two files, four workers allowed. Each file went to its own worker, and inside each file the two tests ran one after another in one worker process. The two files ran at the same time. So the run took about two tests' worth of time (around 4 seconds), not four.
  2. With --fully-parallel, the same four tests spread over four worker processes: the two tests in each file now ran at the same time, in different processes. About one test's worth of time.
  3. Look at the worker counts: the default run said "using 2 workers" although 4 were allowed, because without fullyParallel a whole file is the unit of work, and two files can keep at most two workers busy. The fully parallel run used all 4. Playwright never starts more workers than it has work for, and without a workers setting the cap is half the CPU cores, which is why workers on CI should match the runner's size, not your laptop's.
  4. Nothing in the tests changed between the runs, and both runs passed. That only works because the tests are independent: each opens its own page in its own context. A file whose second test relied on the first (Chapter 3's anti-pattern) would pass in the default run and break with fullyParallel, which is a good reason to turn it on early.
  5. testInfo.workerIndex identifies the worker process (it changes when a worker is replaced after a failure); testInfo.parallelIndex is the "slot", 0 to workers − 1, and stays the same across replacements. Both are also in the environment as TEST_WORKER_INDEX and TEST_PARALLEL_INDEX, which is how per-worker test accounts are usually named (user-${testInfo.parallelIndex}).
AdvancedTest locks (1.63+): when a few tests share something

Sometimes a handful of tests must share a resource that can't be used twice at once: one admin account's settings, a feature flag, a single test mailbox, a third-party sandbox with one slot. Before 1.63 the choices were bad: run the whole suite with one worker, or move those tests into a serial file. A test lock says "tests with this lock name never run at the same time" and lets everything else stay parallel, even across files and projects.

The two suites below are identical except for the lock. Two tests in different files change a "shared account" (a file stands in for a real backend record here; changing it takes 2 seconds, and a test fails if someone else is mid-change):

playwright.config.ts
import { defineConfig } from "@playwright/test";

export default defineConfig({ testDir: "./tests", fullyParallel: true, workers: 4 });
tests/shared-account.ts
// Stands in for a shared test account on a real backend: one record that only one test may change at a time.
import { existsSync, rmSync, writeFileSync } from "node:fs";

const busy = "shared-account.busy";
export async function changeSharedAccount(who: string) {
  if (existsSync(busy)) throw new Error(`${who}: another test was changing the shared account at the same time`);
  writeFileSync(busy, who);
  await new Promise((r) => setTimeout(r, 2000)); // the change takes a while: requests, page loads, checks
  rmSync(busy);
}
tests/display-name.spec.ts
import { test } from "@playwright/test";
import { changeSharedAccount } from "./shared-account";

test("changes the display name", async () => {
  await changeSharedAccount("display name test");
});
tests/newsletter.spec.ts
import { test } from "@playwright/test";
import { changeSharedAccount } from "./shared-account";

test("turns the newsletter on", async () => {
  await new Promise((r) => setTimeout(r, 700)); // starts its change a moment later
  await changeSharedAccount("newsletter test");
});
tests/other.spec.ts
import { test } from "@playwright/test";

test("an unrelated test", async () => {
  await new Promise((r) => setTimeout(r, 500));
});
npx playwright test
Running 3 tests using 3 workers

  ✓  1 tests/other.spec.ts:3:1 › an unrelated test (501ms)
  ✘  2 tests/newsletter.spec.ts:4:1 › turns the newsletter on (704ms)
  ✓  3 tests/display-name.spec.ts:4:1 › changes the display name (2.0s)


  1) tests/newsletter.spec.ts:4:1 › turns the newsletter on ────────────────────────────────────────

    Error: newsletter test: another test was changing the shared account at the same time

       at shared-account.ts:6

      4 | const busy = "shared-account.busy";
      5 | export async function changeSharedAccount(who: string) {
    > 6 |   if (existsSync(busy)) throw new Error(`${who}: another test was changing the shared account at the same time`);
        |                               ^
      7 |   writeFileSync(busy, who);
      8 |   await new Promise((r) => setTimeout(r, 2000)); // the change takes a while: requests, page loads, checks
      9 |   rmSync(busy);
        at changeSharedAccount (<project>/tests/shared-account.ts:6:31)
        at <project>/tests/newsletter.spec.ts:6:9

    Error Context: test-results/newsletter-turns-the-newsletter-on/error-context.md

  1 failed
    tests/newsletter.spec.ts:4:1 › turns the newsletter on ─────────────────────────────────────────
  2 passed (2.2s)

Now the same tests, each declaring lock: "shared-account":

playwright.config.ts
import { defineConfig } from "@playwright/test";

export default defineConfig({ testDir: "./tests", fullyParallel: true, workers: 4 });
tests/shared-account.ts
// Stands in for a shared test account on a real backend: one record that only one test may change at a time.
import { existsSync, rmSync, writeFileSync } from "node:fs";

const busy = "shared-account.busy";
export async function changeSharedAccount(who: string) {
  if (existsSync(busy)) throw new Error(`${who}: another test was changing the shared account at the same time`);
  writeFileSync(busy, who);
  await new Promise((r) => setTimeout(r, 2000)); // the change takes a while: requests, page loads, checks
  rmSync(busy);
}
tests/display-name.spec.ts
import { test } from "@playwright/test";
import { changeSharedAccount } from "./shared-account";

test("changes the display name", { lock: "shared-account" }, async () => {
  await changeSharedAccount("display name test");
});
tests/newsletter.spec.ts
import { test } from "@playwright/test";
import { changeSharedAccount } from "./shared-account";

test("turns the newsletter on", { lock: "shared-account" }, async () => {
  await new Promise((r) => setTimeout(r, 700)); // starts its change a moment later
  await changeSharedAccount("newsletter test");
});
tests/other.spec.ts
import { test } from "@playwright/test";

test("an unrelated test", async () => {
  await new Promise((r) => setTimeout(r, 500));
});
npx playwright test
Running 3 tests using 3 workers

  ✓  1 tests/other.spec.ts:3:1 › an unrelated test (503ms)
  ✓  2 tests/display-name.spec.ts:4:1 › changes the display name (2.0s)
  ✓  3 tests/newsletter.spec.ts:4:1 › turns the newsletter on (2.7s)

  3 passed (4.9s)
What’s happening
  1. Without locks, all three tests start together. The display-name test marks the account busy straight away; the newsletter test arrives 0.7 s later, finds it busy and fails: "another test was changing the shared account at the same time". On a real backend it wouldn't be this polite: both changes would go through and one test would read the other's data, failing at random.
  2. With lock: "shared-account" on both tests, Playwright acquires the lock before a test starts and releases it when it finishes, so the two never overlap: one runs, then the other. The unrelated test, with no lock, still ran in parallel with them. All three pass.
  3. The cost is visible in the durations: the locked tests now take about 2 + 2.7 seconds one after the other instead of overlapping. Locks trade speed for safety on exactly the tests that need it, and nowhere else.
  4. Other forms, from the 1.65 docs and types: several locks on one test (lock: ["database", "external-api"], it waits for all of them); a lock for a whole group with test.describe("…", { lock: "…" }, …) or for a file with test.describe.configure({ lock: "…" }) (1.64+); and the built-in -exclusive- lock (1.65+), which runs a test only when no other test is running, for performance tests or tests that restart a shared service.
  5. A lock is a fix for a shared resource you can't avoid. If you can give each worker its own account or its own data (Chapter 7's worker fixtures), do that instead: it keeps everything parallel.

#Sharding across machines and merging reports

Added

Workers parallelise on one machine. When one machine isn't enough (the suite takes 40 minutes even with all its cores busy), sharding splits the suite across several machines: npx playwright test --shard=1/4 on the first machine runs a quarter of the tests, --shard=2/4 on the second the next quarter, and so on. With fullyParallel: true, tests are divided one by one, which balances well; without it, whole files are divided, and one huge file can leave one shard doing most of the work.

Each shard then has a report of only its quarter. The blob reporter solves that: each shard writes a blob-report/report-N.zip with everything about its run, CI collects the zips into one folder, and npx playwright merge-reports turns them into a single report (HTML, list, JUnit, whatever you ask for) as if it had been one run.

The mental model: exam papers marked by several teachers. Each teacher marks a pile and writes the marks on their own sheet (a blob). The sheets are collected and copied into one class report (the merge). Nobody needs to know which teacher marked which paper, unless they look.

Here's a suite of six tests split into two shards, then merged, the way a CI pipeline does it (the copy step stands in for CI's "upload artifact" and "download artifacts" steps):

playwright.config.ts
import { defineConfig, devices } from "@playwright/test";

export default defineConfig({
  testDir: "./tests",
  fullyParallel: true,
  reporter: [["list"], ["blob"]], // on CI usually: process.env.CI ? "blob" : "html"
  use: { baseURL: "https://rohit-playwright.pages.dev" },
  projects: [{ name: "chromium", use: { ...devices["Desktop Chrome"] } }],
});
tests/signin.spec.ts
import { test, expect, type Page } from "@playwright/test";

async function signIn(page: Page, username: string, password = "playwright") {
  await page.goto("/practice/");
  await page.getByLabel("Username").fill(username);
  await page.getByLabel("Password").fill(password);
  await page.getByRole("button", { name: "Sign in" }).click();
}

test("rohit can sign in", async ({ page }) => {
  await signIn(page, "rohit");
  await expect(page.getByText("Signed in as rohit")).toBeVisible();
});

test("a wrong password is rejected", async ({ page }) => {
  await signIn(page, "rohit", "nope");
  await expect(page.getByRole("alert")).toHaveText("Wrong username or password.");
});

test("the locked account can't sign in", async ({ page }) => {
  await signIn(page, "locked");
  await expect(page.getByRole("alert")).toHaveText("This account is locked. Contact support.");
});
tests/shop.spec.ts
import { test, expect } from "@playwright/test";

test.beforeEach(async ({ page }) => {
  await page.goto("/practice/");
  await page.getByLabel("Username").fill("ana");
  await page.getByLabel("Password").fill("playwright");
  await page.getByRole("button", { name: "Sign in" }).click();
});

test("shows eight products", async ({ page }) => {
  await expect(page.getByRole("listitem")).toHaveCount(8);
});

test("search finds the wireless mouse", async ({ page }) => {
  await page.getByLabel("Search products").fill("wireless");
  await expect(page.getByRole("listitem")).toHaveText([/Wireless Mouse/]);
});

test("the sold-out product can't be added", async ({ page }) => {
  await expect(page.getByRole("listitem").filter({ hasText: "Vertical Mouse" }).getByRole("button")).toBeDisabled();
});
collect-blob.mjs
// Stands in for CI's upload-artifact + download-artifact steps: gathers each shard's blob report into one folder.
import { cpSync, mkdirSync, readdirSync } from "node:fs";
mkdirSync("all-blob-reports", { recursive: true });
for (const f of readdirSync("blob-report")) {
  cpSync(`blob-report/${f}`, `all-blob-reports/${f}`);
  console.log(`blob-report/${f} → all-blob-reports/${f}`);
}
npx playwright test --shard=1/2
Running 3 tests using 3 workers, shard 1 of 2

  ✓  2 [chromium] › tests/shop.spec.ts:10:1 › shows eight products (1.6s)
  ✓  3 [chromium] › tests/shop.spec.ts:19:1 › the sold-out product can't be added (1.6s)
  ✓  1 [chromium] › tests/shop.spec.ts:14:1 › search finds the wireless mouse (1.9s)

  3 passed (2.3s)
node collect-blob.mjs
blob-report/report-1.zip → all-blob-reports/report-1.zip
npx playwright test --shard=2/2
Running 3 tests using 3 workers, shard 2 of 2

  ✓  1 [chromium] › tests/signin.spec.ts:15:1 › a wrong password is rejected (1.0s)
  ✓  3 [chromium] › tests/signin.spec.ts:20:1 › the locked account can't sign in (1.0s)
  ✓  2 [chromium] › tests/signin.spec.ts:10:1 › rohit can sign in (1.1s)

  3 passed (1.6s)
node collect-blob.mjs
blob-report/report-2.zip → all-blob-reports/report-2.zip
npx playwright merge-reports --reporter=list all-blob-reports
Running 6 tests using 6 workers

  ✓  2 [chromium] › tests/shop.spec.ts:10:1 › shows eight products (1.6s)
  ✓  3 [chromium] › tests/shop.spec.ts:19:1 › the sold-out product can't be added (1.6s)
  ✓  1 [chromium] › tests/shop.spec.ts:14:1 › search finds the wireless mouse (1.9s)
  ✓  4 [chromium] › tests/signin.spec.ts:15:1 › a wrong password is rejected (1.0s)
  ✓  6 [chromium] › tests/signin.spec.ts:20:1 › the locked account can't sign in (1.0s)
  ✓  5 [chromium] › tests/signin.spec.ts:10:1 › rohit can sign in (1.1s)

  6 passed (4.3s)
What’s happening
  1. Shard 1 of 2 ran three of the six tests, the header says so ("shard 1 of 2"), and the blob reporter wrote blob-report/report-1.zip. Playwright sorted the tests and gave this shard the first half: here, the three shop tests.
  2. The collect step copies the zip into all-blob-reports/. On CI this is two steps on two different machines: each shard uploads blob-report as an artifact, and the merge job downloads them all into one folder.
  3. Shard 2 of 2 ran the other three (the sign-in tests) and wrote report-2.zip. The shard number in the name is what keeps the two files from overwriting each other when they meet in one folder. (Since 1.65 the blob reporter clears its output folder before writing, so a stale zip from an earlier run on the same machine can't sneak into the merge.)
  4. merge-reports read both zips and printed one list of all 6 tests as a single run. With --reporter=html it writes one playwright-report/ with every test, its traces and screenshots, from every shard; with --reporter=junit one XML file for the CI dashboard. You can pass several, comma-separated.
  5. Shards are just a split of the test list, so every shard must see the same tests (same code, same config, same filters), and each shard installs browsers and starts its own app or points at a shared environment. Four shards cost four machines' setup time; shard when the suite is long enough that the setup is a small part of each shard's time.
AdvancedSharding details worth knowing
  • Balance: with fullyParallel, shards differ by at most one test (ignoring how long each takes); without it, files are dealt out whole. Statically skipped tests (test.skip(), test.fixme()) aren't counted when balancing.
  • Empty shards (1.65 change): the release notes say a sharded run now fails with "No tests found" when no tests match across all shards; --pass-with-no-tests makes it succeed. That matters when a --grep filter or --only-changed leaves nothing to run.
  • Several environments in one report: set tag in the config (for example tag: process.env.CI_ENVIRONMENT_NAME), and the merged report shows which environment each result came from.
  • Merging across operating systems needs a small merge config that sets the tests' root directory, per the docs (npx playwright merge-reports --config merge.config.ts …).
  • The merge config can differ from the test config: the blob holds the raw results, so the merge job decides which reporters to produce.

#A GitHub Actions workflow for Playwright

Added

A CI workflow for Playwright does the same few things everywhere: get the code, install Node and the project's packages, install the browsers and their system libraries, run the tests, and keep the report whether the tests passed or not. At scale it adds a shard matrix and a merge job. The generator from Chapter 2 writes the single-machine version; this one is the sharded version from the Playwright sharding docs, with a few changes explained below. It passes actionlint; it wasn't run on GitHub for this page.

The mental model: an assembly line with a final inspection. Four identical stations (shards) each build a quarter; their output goes on a cart (artifacts); one inspector (the merge job) assembles the report, even if a station broke down.

.github/workflows/playwright.yml
name: Playwright
on:
  push:
    branches: [main]
  pull_request:
    branches: [main]

concurrency:
  group: playwright-${{ github.ref }}
  cancel-in-progress: true

jobs:
  test:
    timeout-minutes: 30
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        shardIndex: [1, 2, 3, 4]
        shardTotal: [4]
    steps:
      - uses: actions/checkout@v6
      - uses: actions/setup-node@v6
        with:
          node-version: lts/*
          cache: npm
      - name: Install dependencies
        run: npm ci
      - name: Install Playwright browsers
        run: npx playwright install --with-deps chromium
      - name: Run Playwright tests
        run: npx playwright test --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }}
      - name: Upload blob report
        if: ${{ !cancelled() }}
        uses: actions/upload-artifact@v5
        with:
          name: blob-report-${{ matrix.shardIndex }}
          path: blob-report
          retention-days: 1

  merge-reports:
    if: ${{ !cancelled() }}
    needs: [test]
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6
      - uses: actions/setup-node@v6
        with:
          node-version: lts/*
          cache: npm
      - run: npm ci
      - name: Download blob reports
        uses: actions/download-artifact@v5
        with:
          path: all-blob-reports
          pattern: blob-report-*
          merge-multiple: true
      - name: Merge into one HTML report
        run: npx playwright merge-reports --reporter html ./all-blob-reports
      - name: Upload HTML report
        uses: actions/upload-artifact@v5
        with:
          name: html-report--attempt-${{ github.run_attempt }}
          path: playwright-report
          retention-days: 14
What’s happening
  1. Triggers and concurrency: runs on pushes to main and on pull requests. concurrency with cancel-in-progress cancels the previous run of the same branch when you push again, so four shards aren't wasted on a commit that's already out of date.
  2. The matrix starts four copies of the test job, with shardIndex 1 to 4. fail-fast: false matters: by default GitHub cancels the other shards when one fails, and you'd lose their results. The config needs reporter: process.env.CI ? "blob" : "html" (or blob added to the list) so each shard writes blob-report/.
  3. Caching: setup-node with cache: npm caches the npm download cache, keyed on package-lock.json. The browsers are not cached: the Playwright CI docs say caching browser binaries isn't recommended, because restoring them takes about as long as downloading them, and the system libraries (--with-deps) can't be cached that way anyway.
  4. npx playwright install --with-deps chromium installs only the browser this suite's projects use, plus the Linux libraries it needs (it uses sudo apt-get on the runner). The generator installs all three browsers; install only what your projects run.
  5. Every shard uploads its blob report even when tests failed: if: ${{ !cancelled() }} runs the step after a failure (but not after a cancel). A report that's only kept on success is useless, because failures are when you need it. Blobs only live a day; they're intermediate.
  6. The merge job waits for all shards (needs: [test]), runs even if some failed (if: ${{ !cancelled() }}), downloads every blob-report-* artifact into one folder (merge-multiple: true), merges them into one HTML report and uploads that for 14 days. Each re-run attempt gets its own artifact name, so a re-run doesn't overwrite the first attempt's report.
  7. Versions: the docs' examples (read 2026-11-24) use actions/checkout@v6, setup-node@v6, upload-artifact@v5 and download-artifact@v5; the 1.65.1 generator in Chapter 2 still wrote @v4. Both work; pin what your organisation allows, and let Dependabot keep them current.
AdvancedWhat the config should do on CI

The workflow is half of it; playwright.config.ts decides how each shard behaves. A typical CI-aware config:

TypeScript
export default defineConfig({
  fullyParallel: true,                         // even shards, and hidden dependencies show up
  forbidOnly: !!process.env.CI,                // a stray test.only fails the build
  retries: process.env.CI ? 2 : 0,             // flaky, not failed, on CI (Chapter 11)
  workers: process.env.CI ? "50%" : undefined, // size to the runner; the docs suggest 1 for maximum stability
  reporter: process.env.CI ? "blob" : [["list"], ["html"]],     // shards write blobs; the merge job makes the reports
  globalTimeout: 60 * 60 * 1000,               // stop the run, with a report, before the job's own timeout
  use: { trace: "on-first-retry", screenshot: "only-on-failure" },
});

This block wasn't run as written (it's the shape, not a suite); each option in it was checked against the 1.65 types. Two notes from the docs: the CI guide recommends workers: 1 on CI "to prioritize stability and reproducibility", which is the safe start for small runners, and many teams raise it once the suite is stable; and the github reporter's annotations aren't recommended with a matrix strategy, because every shard annotates and the stack traces multiply. In the sharded workflow above, leave github out of the shards and add it to the merge step instead (--reporter=html,github).

#Docker and the official image

Added

Playwright's browsers need a lot of system libraries (fonts, graphics, media codecs), and visual tests need the exact same ones every time (Chapter 10). The official image, mcr.microsoft.com/playwright, is Ubuntu with the browsers for one Playwright version and all their dependencies already installed. Use it to run tests in CI without install --with-deps, to make CI and your laptop render identically, and to generate screenshot baselines that match CI.

The one rule that matters: the image version must match your @playwright/test version. The image holds browsers built for one Playwright release; if your project's Playwright is different, the docs warn it "will be unable to locate browser executables". So pin both: @playwright/test@1.65.1 in package.json and mcr.microsoft.com/playwright:v1.65.1-noble in CI. The image doesn't include the @playwright/test package; your project's npm ci installs it.

The mental model: a sealed lab with fixed lighting. Every experiment (test run) happens in the same room with the same equipment, so a different result means the code changed, not the room.

Tags for 1.65.1, as listed by the Microsoft container registry on 2026-11-24 (the docs page itself still showed 1.64.1 examples that day):

TagUbuntu
v1.65.1 / v1.65.1-noble24.04 (noble)
v1.65.1-jammy22.04 (jammy)
v1.65.1-resolute26.04 (resolute)

Per the 1.65 release notes the images now include Node.js 26. Here's the same test job running inside the image instead of installing browsers (it passes actionlint; it wasn't run, and Docker wasn't run for this page either):

.github/workflows/playwright-docker.yml
name: Playwright in Docker
on:
  pull_request:
    branches: [main]
jobs:
  test:
    timeout-minutes: 30
    runs-on: ubuntu-latest
    container:
      image: mcr.microsoft.com/playwright:v1.65.1-noble
      options: --user 1001
    steps:
      - uses: actions/checkout@v6
      - uses: actions/setup-node@v6
        with:
          node-version: lts/*
      - run: npm ci
      - run: npx playwright test
      - uses: actions/upload-artifact@v5
        if: ${{ !cancelled() }}
        with:
          name: playwright-report
          path: playwright-report/
          retention-days: 30
What’s happening
  1. container.image runs every step of the job inside the Playwright image, so there's no browser install step: the browsers and libraries for 1.65.1 are already there.
  2. options: --user 1001 runs as a non-root user, as in the docs' GitHub example. (Chromium's sandbox isn't available as root, which the docs mention for the default root user.)
  3. npm ci installs the project's own @playwright/test, which must be 1.65.1 to match the image. When you upgrade Playwright, the image tag changes in the same pull request.
  4. The report upload works as in the generator's workflow. Visual baselines generated with this same image (next block) will match what this job renders.
AdvancedRunning the image on your Mac

The docs' commands, adapted to this project (not run for this page):

Shell
# A shell inside the image, with the project mounted at /work (trusted sites only: runs as root):
docker run -it --rm --ipc=host -v "$PWD":/work -w /work mcr.microsoft.com/playwright:v1.65.1-noble /bin/bash

# Inside it: install the project's packages and update visual baselines for Linux.
npm ci
npx playwright test --update-snapshots --grep @visual
  • --ipc=host is recommended for Chromium, which can otherwise run out of shared memory and crash; --init avoids zombie processes from PID 1.
  • -v "$PWD":/work mounts your project, so the -linux.png baselines land in your working copy, ready to commit. On an Apple-silicon Mac Docker runs the arm64 image; most teams generate baselines on the same architecture CI uses, so check yours.
  • For scraping or untrusted sites the docs recommend --user pwuser and a seccomp profile instead of running as root.
  • The docs also describe running a Playwright server in the image (npx -y playwright@1.65.1 run-server --port 3000 --host 0.0.0.0) and pointing tests at it with PW_TEST_CONNECT_WS_ENDPOINT=ws://127.0.0.1:3000/, so tests run on your Mac but the browsers render in Linux.
  • Alpine images aren't supported: Firefox and WebKit need glibc.

#Reporters

Added

A reporter decides what a run prints and what files it leaves behind. One run can have several (reporter: [["list"], ["html"]]), and --reporter=… on the command line replaces the config's choice; --add-reporter (1.63+) adds one on top instead. The built-in ones, from the 1.65 docs:

ReporterPrints or writesUse it for
listone line per test (the default locally)your terminal
lineone updating line, failures as they happenbig suites in a terminal
dotone character per test (the default on CI)compact CI logs
failures (1.65+)only failures and successful retries, as they happen, then a summaryCI logs where only problems matter
htmla browsable report folder with traces, screenshots, diffshumans investigating failures
junitJUnit XMLCI dashboards (Jenkins, GitLab, Azure DevOps)
jsoneverything as JSONyour own tooling, metrics
githubGitHub Actions annotations on the failing linesGitHub, single job (not a matrix)
bloba zip with everything, for merging latersharded runs

The mental model: the same match, reported by different media. A live ticker (dot, line), a full broadcast with replays (html), the official scoresheet for the league table (junit), and the raw data feed (json, blob). The match is identical; who it's for differs.

This suite has one of each outcome: a pass, a failure (a wrong expectation, standing in for a real bug), a flaky test and a skipped one, with one retry allowed. The same run, through three terminal reporters:

playwright.config.ts
import { defineConfig, devices } from "@playwright/test";

export default defineConfig({
  testDir: "./tests",
  retries: 1,
  use: { baseURL: "https://rohit-playwright.pages.dev" },
  projects: [{ name: "chromium", use: { ...devices["Desktop Chrome"] } }],
});
tests/outcomes.spec.ts
import { test, expect } from "@playwright/test";

test("passes: the sign-in heading", async ({ page }) => {
  await page.goto("/practice/");
  await expect(page.getByRole("heading", { name: "Sign in" })).toBeVisible();
});

test("fails: the wrong-password message", async ({ page }) => {
  await page.goto("/practice/");
  await page.getByLabel("Username").fill("rohit");
  await page.getByLabel("Password").fill("nope");
  await page.getByRole("button", { name: "Sign in" }).click();
  await expect(page.getByRole("alert")).toHaveText("Incorrect password.", { timeout: 3000 });
});

test("flaky: passes on the retry", async ({}, testInfo) => {
  expect(testInfo.retry, "fails on the first attempt on purpose").toBe(1);
});

test.skip("skipped: password reset (not built yet)", async () => {});
npx playwright test --reporter=dot
Running 4 tests using 1 worker
·×F×±°

  1) [chromium] › tests/outcomes.spec.ts:8:1 › fails: the wrong-password message ───────────────────

    Error: expect(locator).toHaveText(expected) failed

    Locator:  getByRole('alert')
    Expected: "Incorrect password."
    Received: "Wrong username or password."
    Timeout:  3000ms

    Call log:
      - Expect "toHaveText" getByRole('alert') with timeout 3000ms
      - waiting for getByRole('alert')
        5 × locator resolved to <p role="alert" class="alert" data-login-error="">Wrong username or password.</p>
          - unexpected value "Wrong username or password."


      11 |   await page.getByLabel("Password").fill("nope");
      12 |   await page.getByRole("button", { name: "Sign in" }).click();
    > 13 |   await expect(page.getByRole("alert")).toHaveText("Incorrect password.", { timeout: 3000 });
         |                                         ^
      14 | });
      15 |
      16 | test("flaky: passes on the retry", async ({}, testInfo) => {
        at <project>/tests/outcomes.spec.ts:13:41

    Error Context: test-results/outcomes-fails-the-wrong-password-message-chromium/error-context.md

    Retry #1 ───────────────────────────────────────────────────────────────────────────────────────

    Error: expect(locator).toHaveText(expected) failed

    Locator:  getByRole('alert')
    Expected: "Incorrect password."
    Received: "Wrong username or password."
    Timeout:  3000ms

    Call log:
      - Expect "toHaveText" getByRole('alert') with timeout 3000ms
      - waiting for getByRole('alert')
        5 × locator resolved to <p role="alert" class="alert" data-login-error="">Wrong username or password.</p>
          - unexpected value "Wrong username or password."


      11 |   await page.getByLabel("Password").fill("nope");
      12 |   await page.getByRole("button", { name: "Sign in" }).click();
    > 13 |   await expect(page.getByRole("alert")).toHaveText("Incorrect password.", { timeout: 3000 });
         |                                         ^
      14 | });
      15 |
      16 | test("flaky: passes on the retry", async ({}, testInfo) => {
        at <project>/tests/outcomes.spec.ts:13:41

    Error Context: test-results/outcomes-fails-the-wrong-password-message-chromium-retry1/error-context.md

  2) [chromium] › tests/outcomes.spec.ts:16:1 › flaky: passes on the retry ─────────────────────────

    Error: fails on the first attempt on purpose

    expect(received).toBe(expected) // Object.is equality

    Expected: 1
    Received: 0

      15 |
      16 | test("flaky: passes on the retry", async ({}, testInfo) => {
    > 17 |   expect(testInfo.retry, "fails on the first attempt on purpose").toBe(1);
         |                                                                   ^
      18 | });
      19 |
      20 | test.skip("skipped: password reset (not built yet)", async () => {});
        at <project>/tests/outcomes.spec.ts:17:67

    Error Context: test-results/outcomes-flaky-passes-on-the-retry-chromium/error-context.md

  1 failed
    [chromium] › tests/outcomes.spec.ts:8:1 › fails: the wrong-password message ────────────────────
  1 flaky
    [chromium] › tests/outcomes.spec.ts:16:1 › flaky: passes on the retry ──────────────────────────
  1 skipped
  1 passed (7.9s)
npx playwright test --reporter=failures
  1) [chromium] › tests/outcomes.spec.ts:8:1 › fails: the wrong-password message ───────────────────

    Error: expect(locator).toHaveText(expected) failed

    Locator:  getByRole('alert')
    Expected: "Incorrect password."
    Received: "Wrong username or password."
    Timeout:  3000ms

    Call log:
      - Expect "toHaveText" getByRole('alert') with timeout 3000ms
      - waiting for getByRole('alert')
        5 × locator resolved to <p role="alert" class="alert" data-login-error="">Wrong username or password.</p>
          - unexpected value "Wrong username or password."


      11 |   await page.getByLabel("Password").fill("nope");
      12 |   await page.getByRole("button", { name: "Sign in" }).click();
    > 13 |   await expect(page.getByRole("alert")).toHaveText("Incorrect password.", { timeout: 3000 });
         |                                         ^
      14 | });
      15 |
      16 | test("flaky: passes on the retry", async ({}, testInfo) => {
        at <project>/tests/outcomes.spec.ts:13:41

    Error Context: test-results/outcomes-fails-the-wrong-password-message-chromium/error-context.md

  1) [chromium] › tests/outcomes.spec.ts:8:1 › fails: the wrong-password message ───────────────────

    Retry #1 ───────────────────────────────────────────────────────────────────────────────────────

    Error: expect(locator).toHaveText(expected) failed

    Locator:  getByRole('alert')
    Expected: "Incorrect password."
    Received: "Wrong username or password."
    Timeout:  3000ms

    Call log:
      - Expect "toHaveText" getByRole('alert') with timeout 3000ms
      - waiting for getByRole('alert')
        5 × locator resolved to <p role="alert" class="alert" data-login-error="">Wrong username or password.</p>
          - unexpected value "Wrong username or password."


      11 |   await page.getByLabel("Password").fill("nope");
      12 |   await page.getByRole("button", { name: "Sign in" }).click();
    > 13 |   await expect(page.getByRole("alert")).toHaveText("Incorrect password.", { timeout: 3000 });
         |                                         ^
      14 | });
      15 |
      16 | test("flaky: passes on the retry", async ({}, testInfo) => {
        at <project>/tests/outcomes.spec.ts:13:41

    Error Context: test-results/outcomes-fails-the-wrong-password-message-chromium-retry1/error-context.md

  2) [chromium] › tests/outcomes.spec.ts:16:1 › flaky: passes on the retry ─────────────────────────

    Error: fails on the first attempt on purpose

    expect(received).toBe(expected) // Object.is equality

    Expected: 1
    Received: 0

      15 |
      16 | test("flaky: passes on the retry", async ({}, testInfo) => {
    > 17 |   expect(testInfo.retry, "fails on the first attempt on purpose").toBe(1);
         |                                                                   ^
      18 | });
      19 |
      20 | test.skip("skipped: password reset (not built yet)", async () => {});
        at <project>/tests/outcomes.spec.ts:17:67

    Error Context: test-results/outcomes-flaky-passes-on-the-retry-chromium/error-context.md

  2) [chromium] › tests/outcomes.spec.ts:16:1 › flaky: passes on the retry ─────────────────────────
    Passed on retry #1 (6ms).

  1 failed
    [chromium] › tests/outcomes.spec.ts:8:1 › fails: the wrong-password message ────────────────────
  1 flaky
    [chromium] › tests/outcomes.spec.ts:16:1 › flaky: passes on the retry ──────────────────────────
  1 skipped
  1 passed (9.2s)
What’s happening
  1. dot prints one character per attempt on a single line: · pass, × a failure that will be retried, F a final failure, ± flaky, ° skipped. Here, ·×F×±° reads: the pass; the wrong-password test failing (×), retried and failing again (F); the flaky test failing (×) and then passing on its retry (±); the skip. Then the failure details and the summary.
  2. In the failure details, the failing test is printed twice: the first attempt, then "Retry #1" with the same error. A test that fails the same way on every retry is a real failure (or a real bug), not a flake.
  3. The summary separates the outcomes: 1 failed, 1 flaky, 1 skipped, 1 passed. Four tests, four different results, and none of them hidden inside another.
  4. failures (1.65+) prints nothing for the tests that simply passed: no progress line at all. It prints each failure as it happens, and for the flaky test it prints the failing attempt and then "Passed on retry #1". The release notes describe it as failures and successful retries as they occur, followed by a summary, without progress output. It's built for long CI logs where you scroll straight to what went wrong; the docs suggest pairing it with html.
  5. The skipped test appears only in the summary. It never ran, so there was nothing to report while running.
Advancedline, junit, json and github, from the same run

The line reporter prints one line that updates in a real terminal (in a log, each update is its own line). The file reporters write XML or JSON; the two scripts below print the parts that don't change from run to run (the files also hold timings and timestamps). And github prints workflow commands that GitHub turns into annotations; the third script shows just their headers, because each annotation carries the whole error message encoded on one line.

junit-summary.mjs
// Runs the suite with the junit reporter into a file, then prints the stable parts of the XML.
import { execFileSync } from "node:child_process";
import { readFileSync } from "node:fs";
try {
  execFileSync("npx", ["playwright", "test", "--reporter=junit"], { env: { ...process.env, PLAYWRIGHT_JUNIT_OUTPUT_NAME: "results.xml" }, stdio: "ignore" });
} catch {} // the run fails (one test fails), which is expected here
const xml = readFileSync("results.xml", "utf8");
console.log(xml.match(/<testsuites [^>]*>/)[0].replace(/ time="[^"]*"/, ""));
for (const m of xml.matchAll(/<testcase name="([^"]*)"[^>]*>([\s\S]*?)<\/testcase>/g)) {
  const outcome = m[2].includes("<failure") ? "failure" : m[2].includes("<skipped") ? "skipped" : "ok";
  console.log(`  testcase "${m[1]}": ${outcome}`);
}
node junit-summary.mjs
<testsuites id="" name="" tests="4" failures="1" skipped="1" errors="0">
  testcase "passes: the sign-in heading": ok
  testcase "fails: the wrong-password message": failure
  testcase "flaky: passes on the retry": ok
  testcase "skipped: password reset (not built yet)": skipped
json-summary.mjs
// Runs the suite with the json reporter (it prints to stdout) and shows the stats and each test's final status.
import { spawnSync } from "node:child_process";
const run = spawnSync("npx", ["playwright", "test", "--reporter=json"], { encoding: "utf8" });
const report = JSON.parse(run.stdout);
const { expected, unexpected, flaky, skipped } = report.stats;
console.log({ expected, unexpected, flaky, skipped });
for (const spec of report.suites[0].specs) console.log(`${spec.title}: ${spec.tests[0].status}, attempts: ${spec.tests[0].results.length}`);
node json-summary.mjs
{ expected: 1, unexpected: 1, flaky: 1, skipped: 1 }
passes: the sign-in heading: expected, attempts: 1
fails: the wrong-password message: unexpected, attempts: 2
flaky: passes on the retry: flaky, attempts: 2
skipped: password reset (not built yet): skipped, attempts: 1
github-annotations.mjs
// Runs the suite with the github reporter and prints only the head of each workflow command (::error, ::notice …).
import { spawnSync } from "node:child_process";
const run = spawnSync("npx", ["playwright", "test", "--reporter=github"], { encoding: "utf8" });
for (const line of run.stdout.split("\n").filter((l) => l.startsWith("::"))) console.log(line.slice(0, line.indexOf("::", 2) + 2));
node github-annotations.mjs
::error file=tests/outcomes.spec.ts,title=[chromium] › tests/outcomes.spec.ts%3A8%3A1 › fails%3A the wrong-password message,line=13,col=41::
::error file=tests/outcomes.spec.ts,title=[chromium] › tests/outcomes.spec.ts%3A8%3A1 › fails%3A the wrong-password message,line=13,col=41::
::error file=tests/outcomes.spec.ts,title=[chromium] › tests/outcomes.spec.ts%3A16%3A1 › flaky%3A passes on the retry,line=17,col=67::
::notice title=🎭 Playwright Run Summary::
What’s happening
  1. JUnit: one <testsuites> element with the totals (4 tests, 1 failure, 1 skipped), then one <testcase> per test. The flaky test counts as ok: this summary has no "flaky" state, so a dashboard fed only by JUnit can't tell a flaky test from a solid one. (The 1.65 types also list an includeRetries option for junit; it wasn't tried here.) For flake tracking, read the JSON. The file goes where PLAYWRIGHT_JUNIT_OUTPUT_NAME (or outputFile in the config) says.
  2. JSON: the stats use the runner's own words: expected (passed as expected), unexpected (failed), flaky, skipped. Each test's final status is "expected", "unexpected", "flaky" or "skipped", and results holds every attempt, so the failing and flaky tests show 2 attempts. This is the reporter to build flake-rate tracking on.
  3. GitHub: one ::error per failed attempt, carrying the file, the line and column of the failing assertion and a title, which GitHub draws as a red annotation on that line of the pull request's diff, plus a ::notice with the run summary. The flaky test's first attempt is annotated too.
  4. With four shards each running the github reporter, every failure would be annotated by the shard that ran it and the summary notice would appear four times, which is why the docs advise against it in a matrix. Run it once, in the merge job.
AdvancedThe html report

html writes playwright-report/ (change it with outputFolder or PLAYWRIGHT_HTML_OUTPUT_DIR). By default it opens a browser only when something failed (open: "on-failure"); on CI set open: "never". npx playwright show-report serves the last one, and since 1.60 also accepts a .zip of a report. For each test it shows the steps, errors, attachments (screenshots, the visual diff with a slider, traces), and since 1.57 a "Speedboard" tab for finding slow tests. onlyFailures (1.65+, also for json and junit) leaves passing tests out to keep big reports small. The report is a window, so it wasn't opened for this page.

#Keeping a big suite fast

Added

A suite of 30 tests that takes 2 minutes is a pleasure. The same team, two years later, has 900 tests that take 50 minutes, so people stop running them before pushing, merge on red "because it's always flaky", and the suite stops protecting anything. Speed is a feature of a test suite, and it's mostly decided by what you choose to test end to end, not by Playwright settings.

The mental model: the test pyramid. Many fast unit tests at the bottom, fewer integration and API tests in the middle, a small number of E2E tests at the top covering the journeys only a real browser can prove (Chapter 3). A suite shaped like an ice-cream cone (mostly E2E, few unit tests) is slow and flaky no matter how many shards you buy.

What to keep end to end, and what to push down:

Keep as E2EPush down to API, component or unit tests
sign-in, checkout, the money pathevery validation rule, every pricing edge case
one happy path per critical journeyevery combination of filters and sorts
one "errors are shown and block the action" test per formeach individual error message
cross-page state (cart cleared after ordering)a component rendering in 12 states
wiring between front end and APIthe API's own contract and edge cases (request fixture, Chapter 9)

The levers, roughly in order of how much they usually save (rules of thumb, not measurements):

  1. Don't do through the UI what isn't being tested. Sign in once with a setup project and reuse storageState (Chapter 8); create test data through the API (Chapter 9). A test that spends 4 seconds on setup and 1 second on its actual check is 80% waste.
  2. Mock what's slow and not yours (third-party scripts, payment providers, slow reports) with page.route (Chapter 9), and keep a few tests against the real thing.
  3. Parallelise properly: fullyParallel: true, independent tests, workers sized to the runner. Then shard across machines when one machine isn't enough.
  4. Run less on each change: a tagged smoke set on every pull request (--grep @smoke, Chapter 2) and the full suite on main and nightly; --only-changed [ref] runs only test files changed between HEAD and a git ref (by default, uncommitted changes); --last-failed re-runs only failures locally.
  5. Stop early when it's hopeless: maxFailures (or -x for the first failure) stops a run that's clearly broken instead of waiting for 900 timeouts.
  6. Fix the slowest tests: the HTML report's Speedboard, or the JSON reporter's durations, show where the time goes. Look for fixed sleeps, generous timeouts that hide waiting for the wrong thing, and tests that test five things.
  7. Fewer browsers per change: Chromium on every pull request; Firefox, WebKit and mobile projects nightly, unless you've seen browser-specific bugs in that area.

#Your turn: scale the shop's suite

Added
Your turn: three shards and one merged report

Split this chapter's six shop and sign-in tests into three shards with the blob reporter, collect the blobs, and merge them into one list report. Predict how many tests each shard runs before you look.

Show answer
playwright.config.ts
import { defineConfig, devices } from "@playwright/test";

export default defineConfig({
  testDir: "./tests",
  fullyParallel: true,
  reporter: [["dot"], ["blob"]],
  use: { baseURL: "https://rohit-playwright.pages.dev" },
  projects: [{ name: "chromium", use: { ...devices["Desktop Chrome"] } }],
});
tests/shop.spec.ts
import { test, expect } from "@playwright/test";

test.beforeEach(async ({ page }) => {
  await page.goto("/practice/");
  await page.getByLabel("Username").fill("ana");
  await page.getByLabel("Password").fill("playwright");
  await page.getByRole("button", { name: "Sign in" }).click();
});

test("shows eight products", async ({ page }) => {
  await expect(page.getByRole("listitem")).toHaveCount(8);
});
test("search finds the wireless mouse", async ({ page }) => {
  await page.getByLabel("Search products").fill("wireless");
  await expect(page.getByRole("listitem")).toHaveText([/Wireless Mouse/]);
});
test("the category filter shows only audio", async ({ page }) => {
  await page.getByLabel("Category").selectOption("Audio");
  await expect(page.getByRole("listitem")).toHaveCount(2);
});
test("the sold-out product can't be added", async ({ page }) => {
  await expect(page.getByRole("listitem").filter({ hasText: "Vertical Mouse" }).getByRole("button")).toBeDisabled();
});
test("adding a product updates the cart count", async ({ page }) => {
  await page.getByRole("listitem").filter({ hasText: "USB Microphone" }).getByRole("button", { name: "Add to cart" }).click();
  await expect(page.getByRole("link", { name: "Cart (1)" })).toBeVisible();
});
test("signing out returns to the sign-in page", async ({ page }) => {
  await page.getByRole("button", { name: "Log out" }).click();
  await expect(page.getByRole("heading", { name: "Sign in" })).toBeVisible();
});
collect-blob.mjs
// Stands in for CI's upload-artifact + download-artifact steps: gathers each shard's blob report into one folder.
import { cpSync, mkdirSync, readdirSync } from "node:fs";
mkdirSync("all-blob-reports", { recursive: true });
for (const f of readdirSync("blob-report")) {
  cpSync(`blob-report/${f}`, `all-blob-reports/${f}`);
  console.log(`blob-report/${f} → all-blob-reports/${f}`);
}
npx playwright test --shard=1/3
Running 2 tests using 2 workers, shard 1 of 3
··
  2 passed (2.4s)
node collect-blob.mjs
blob-report/report-1.zip → all-blob-reports/report-1.zip
npx playwright test --shard=2/3
Running 2 tests using 2 workers, shard 2 of 3
··
  2 passed (2.1s)
node collect-blob.mjs
blob-report/report-2.zip → all-blob-reports/report-2.zip
npx playwright test --shard=3/3
Running 2 tests using 2 workers, shard 3 of 3
··
  2 passed (1.8s)
node collect-blob.mjs
blob-report/report-3.zip → all-blob-reports/report-3.zip
npx playwright merge-reports --reporter=list all-blob-reports
Running 6 tests using 6 workers

  ✓  1 [chromium] › tests/shop.spec.ts:10:1 › shows eight products (1.5s)
  ✓  2 [chromium] › tests/shop.spec.ts:13:1 › search finds the wireless mouse (1.8s)
  ✓  4 [chromium] › tests/shop.spec.ts:21:1 › the sold-out product can't be added (1.5s)
  ✓  3 [chromium] › tests/shop.spec.ts:17:1 › the category filter shows only audio (1.7s)
  ✓  5 [chromium] › tests/shop.spec.ts:28:1 › signing out returns to the sign-in page (1.0s)
  ✓  6 [chromium] › tests/shop.spec.ts:24:1 › adding a product updates the cart count (1.5s)

  6 passed (6.8s)
What’s happening
  1. Six tests, fullyParallel, three shards: two tests per shard, because sharding at test level divides them evenly. Without fullyParallel all six would be one file, and shard 1 would get the whole file while shards 2 and 3 got nothing (and, since 1.65, an empty shard set fails with "No tests found" unless you pass --pass-with-no-tests).
  2. Each shard uses the dot reporter for its own log and the blob reporter for the merge: two dots per shard, and report-1.zip, report-2.zip, report-3.zip.
  3. The collect step puts the three zips side by side, as the merge job's download step would.
  4. merge-reports --reporter=list prints all six tests as one run. With --reporter=html you'd get one browsable report for the whole suite, which is what you'd upload from CI.
Your turn: a smoke workflow for pull requests and a full nightly run

Write a workflow that runs only @smoke tests in Chromium on every pull request, and the full suite in all browser projects every night at 03:00 UTC. It must pass actionlint.

Show answer
.github/workflows/e2e.yml
name: E2E
on:
  pull_request:
    branches: [main]
  schedule:
    - cron: "0 3 * * *"

jobs:
  smoke:
    if: ${{ github.event_name == 'pull_request' }}
    timeout-minutes: 15
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6
      - uses: actions/setup-node@v6
        with:
          node-version: lts/*
          cache: npm
      - run: npm ci
      - run: npx playwright install --with-deps chromium
      - run: npx playwright test --project=chromium --grep @smoke
      - uses: actions/upload-artifact@v5
        if: ${{ !cancelled() }}
        with:
          name: smoke-report
          path: playwright-report/
          retention-days: 7

  full:
    if: ${{ github.event_name == 'schedule' }}
    timeout-minutes: 60
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        project: [chromium, firefox, webkit]
    steps:
      - uses: actions/checkout@v6
      - uses: actions/setup-node@v6
        with:
          node-version: lts/*
          cache: npm
      - run: npm ci
      - run: npx playwright install --with-deps ${{ matrix.project }}
      - run: npx playwright test --project=${{ matrix.project }}
      - uses: actions/upload-artifact@v5
        if: ${{ !cancelled() }}
        with:
          name: nightly-report-${{ matrix.project }}
          path: playwright-report/
          retention-days: 14
What’s happening
  1. Two triggers: pull_request for every PR to main, and schedule with the cron expression 0 3 * * * (minute 0, hour 3, every day; GitHub's schedule times are UTC).
  2. Each job has an if on github.event_name, so a PR runs only smoke and the nightly run only full.
  3. Smoke installs only Chromium and runs --project=chromium --grep @smoke: the handful of tagged tests, minutes not hours.
  4. Full uses a matrix over the three browser projects (this assumes projects named chromium, firefox and webkit in the config, as in Chapter 2), installs only the browser each copy needs, and keeps every report, with fail-fast: false so one browser's failure doesn't cancel the others. To shard each browser too, add a shardIndex dimension and the blob/merge steps from the main workflow.
  5. It passes actionlint (the site's checker runs it on every block like this); it wasn't run on GitHub.

Written fresh, no doc. Tests were run with @playwright/test 1.65.1 (Chrome for Testing 159, Firefox 159, WebKit 27.2) against the Practice Shop at /practice/; facts come from playwright.dev, read 2026-11-24.

RohitDownloads · All chapters

Sync progress across devices

Type the same private phrase on your Mac and your phone, and your Learned ticks follow you between them — on every study site.

The phrase never leaves this device: only a fingerprint of it is sent, and the server stores a fingerprint of that. Anyone who knows the phrase could see or change your ticks, so pick something you don’t use elsewhere.

Sync is on in this browser.

Sync ID

This ID must be the same on every device. If another device shows a different one, its phrase is different (capital letters count): tap “Turn off here” on it and type the phrase again exactly.