PRACTICAL GUIDE / playwright sharding merge reports

Shard Playwright Tests and Merge Reports Across CI Jobs

Split Playwright tests across balanced CI shards, preserve blob artifacts, and merge every job into one trustworthy HTML report with attachments.

By The Testing AcademyUpdated July 11, 20268 min read
All field guides
In this guide10 sections
  1. Decide whether sharding addresses the actual bottleneck
  2. Configure the runner for mergeable output
  3. Dispatch one shard per CI matrix entry
  4. Isolate data and resources across jobs
  5. Merge all blob artifacts in a dependent job
  6. Preserve identity across environments and projects
  7. Balance by observed duration, not file count alone
  8. Diagnose incomplete or inconsistent merged reports
  9. Operational sharding checklist
  10. Roll out sharding as a complete reporting system

What you will learn

  • Decide whether sharding addresses the actual bottleneck
  • Configure the runner for mergeable output
  • Dispatch one shard per CI matrix entry
  • Isolate data and resources across jobs

Sharding shortens a Playwright pipeline only when the work is divided cleanly and the evidence is reassembled afterward. Four jobs that finish at very different times create little benefit, and four isolated HTML reports force reviewers to hunt for the real result. A production-ready design treats test distribution and report merging as one workflow.

The contract is straightforward: every shard receives the same source revision, dependency graph, Playwright configuration, and test inventory; each receives a unique partition; every job uploads a blob report even on failure; and a downstream job verifies the artifact set before producing one report. Missing any part can yield a fast but incomplete signal.

Decide whether sharding addresses the actual bottleneck

Measure the existing job before adding machines. If most time is spent installing dependencies, building the application, or waiting for a shared environment, splitting only test execution may multiply setup cost without improving completion time. Sharding is most effective when test execution is a substantial, parallel-safe part of the critical path.

Confirm that tests can run independently across machines. Shared accounts, static database records, global rate limits, and one mutable deployment can turn added concurrency into collisions. Fix resource isolation before increasing shard count, or the pipeline will exchange duration for flakiness.

The official Playwright sharding guide uses --shard=current/total and explains the balance difference between test-level and file-level distribution. Treat the total as a versioned CI decision. Changing it alters which tests land together and can expose hidden dependencies.

Animated field map

Sharded execution and report merge

Partition one stable inventory, retain each job's evidence, and publish a verified unified report.

  1. 01 / test inventory

    Test inventory

    Resolve the same revision, projects, filters, and configuration in every job.

  2. 02 / balanced shards

    Balanced shards

    Divide at test or file granularity according to parallel settings.

  3. 03 / parallel jobs

    Parallel CI jobs

    Run unique shard indexes with isolated data and equal resources.

  4. 04 / blob artifacts

    Blob artifacts

    Upload results, traces, screenshots, and metadata from every shard.

  5. 05 / unified report

    Unified HTML report

    Validate the artifact set, merge it, and publish one review surface.

Configure the runner for mergeable output

Use the blob reporter in CI and a human-friendly reporter locally. Blob output contains results and attachments in a mergeable format; it is an interchange artifact, not usually the final interface reviewers open.

fullyParallel: true allows Playwright to balance individual tests across shards. Without it, whole files are assigned, so a file containing many slow scenarios can dominate one job. Enabling full parallelism also allows tests from a file to run concurrently, so first remove assumptions about file order and shared mutable state.

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

export default defineConfig({
  testDir: './tests/e2e',
  fullyParallel: true,
  retries: process.env.CI ? 1 : 0,
  reporter: process.env.CI
    ? [['blob']]
    : [['html', { open: 'never' }]],
  use: {
    trace: 'on-first-retry',
    screenshot: 'only-on-failure',
  },
});

Keep filters identical across matrix jobs. If one shard adds --grep @smoke while another runs the full inventory, the merged report does not represent a valid partition. Browser projects, environment tags, and feature flags also belong to the stable input contract.

Dispatch one shard per CI matrix entry

A matrix makes the current and total shard values explicit. The shard number is one-based, so a four-job setup runs 1/4, 2/4, 3/4, and 4/4. Set fail-fast: false so one regression does not cancel other shards and erase their coverage.

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

The upload condition matters. A test command returns a failure exit code for a regression, but that shard's blob report contains the failure evidence the merged report needs. !cancelled() preserves normal failures while respecting a manually cancelled workflow.

Isolate data and resources across jobs

Machines do not share a Playwright worker index, so a worker-derived account name alone may collide across shards. Include a run identifier, shard index, project, and parallel index in resource namespaces when the external system requires uniqueness. Keep names within database and provider limits.

Provision data through APIs or fixtures that can tolerate retry and partial teardown. A shard may be restarted by CI, and a Playwright worker may restart after a test failure. Cleanup should target the exact namespace rather than a broad shared tenant.

If the application environment has a concurrency ceiling, increasing shards can overload it and lengthen every request. Match shard count to both CI capacity and system-under-test capacity. A stable two-shard run can be more useful than eight competing jobs.

Merge all blob artifacts in a dependent job

The merge job should wait for every shard but run even when one fails. Download blob artifacts into one directory, verify the expected count, and invoke merge-reports. The command can generate HTML or multiple report formats from the same blob inputs.

YAML
  merge-reports:
    if: ${{ !cancelled() }}
    needs: [playwright-tests]
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v5
      - uses: actions/setup-node@v5
        with:
          node-version: lts/*
      - run: npm ci
      - uses: actions/download-artifact@v5
        with:
          path: all-blob-reports
          pattern: blob-report-*
          merge-multiple: true
      - name: Merge shard reports
        run: npx playwright merge-reports --reporter=html ./all-blob-reports
      - uses: actions/upload-artifact@v4
        with:
          name: playwright-html-report
          path: playwright-report
          retention-days: 14

For a hardened workflow, add a shell check that the directory contains the expected number of blob archives before merging. Otherwise a missing upload can produce a polished partial report. The test job status still protects the pipeline, but reviewers should never mistake incomplete evidence for full execution.

Preserve identity across environments and projects

Sharding divides one logical inventory. Running the same tests against staging and preview, or Linux and Windows, is a different dimension. Tag those environments in configuration so merged results remain distinguishable. Do not use shard numbers as environment labels; they are distribution details and can change.

When merging output produced on different operating systems, provide an explicit merge configuration if test roots are ambiguous. Keep checkout paths and testDir semantics compatible. A blob file can be valid on its own while the merge cannot map its source location to the current workspace.

Artifact names should include the workflow attempt when reruns can coexist. A rerun of one failed CI job must not accidentally merge three artifacts from the previous attempt with one new artifact. Prefer immutable run-scoped storage or clear the destination before download.

Balance by observed duration, not file count alone

With full parallelism, Playwright distributes individual tests, which usually improves balance. Yet test count is only a proxy for duration. A few authentication or visual tests may still dominate a shard. Inspect per-shard completion times and identify consistent outliers.

Without full parallelism, keep files small enough that one file cannot monopolize a partition. Splitting a large file is reasonable when it reflects independent domains. Do not fracture coherent setup purely to chase equal file counts if the result creates duplication or hidden order dependencies.

Increasing the number of shards eventually reaches diminishing returns because every job repeats checkout, install, application startup, and artifact work. Select the smallest count that meets the pipeline objective with stable resource use, then revisit it as the inventory changes.

Diagnose incomplete or inconsistent merged reports

If tests are absent, compare the discovered test count from each shard and confirm all indexes share the same total. Check filters, project selection, and whether one job failed before producing blob output. A successful merge proves that readable artifacts were combined, not that the inventory was complete.

If attachments are missing, verify trace and screenshot configuration on shard jobs and confirm the artifact upload includes the whole blob-report directory. Do not upload only a report archive selected by a brittle filename pattern.

Duplicate tests usually indicate overlapping shard commands, stale artifacts, or mixed workflow attempts. Clear the download directory, scope artifacts by run, and inspect blob filenames for shard identity. Source-path errors during merge point toward different checkout layouts or an incorrect testDir in the merge context.

Operational sharding checklist

  • Measure execution time separately from setup and artifact time.
  • Confirm tests and external data are parallel-safe.
  • Give every job the same commit, lockfile, config, projects, and filters.
  • Use each one-based shard index exactly once.
  • Enable full parallelism only after removing file-order coupling.
  • Keep matrix fail-fast disabled for complete evidence.
  • Upload blob output when tests fail.
  • Verify all expected blob artifacts before merging.
  • Keep workflow attempts and environments distinguishable.
  • Review shard duration and capacity after suite growth.

Roll out sharding as a complete reporting system

Begin with two partitions and record both job duration and test discovery. Add blob output, an always-run upload, and a dependent merge job before expanding the matrix. Inject one controlled failing test to confirm that its trace appears in the unified report and the workflow still returns the correct failure status. Once completeness, isolation, and artifact identity are proven, tune shard count from observed capacity. That sequence delivers faster feedback without sacrificing the single trustworthy result reviewers need.

// LIVE COURSE / THE TESTING ACADEMY

Playwright Automation Mastery

Go beyond Selenium. Master Playwright with JS/TS in 90 days.

From the instructor behind this guide.

Playwright jobs are growing 8x faster than Selenium. 90 days / 75+ live hrs / Tue-Thu-Sat 7 AM IST.

Code PROMODE / 10% offJoin the batch

The Testing Academy editorial desk

Practical QA guidance built around test evidence, production tradeoffs, and interview-ready explanations.

Published July 11, 2026 / Reviewed July 11, 2026

PRIMARY REFERENCES

Verify the details at the source

QABattle guides are practical explanations. Product behavior, standards, and APIs can change, so use these primary references for the canonical details.

  1. 01
    Playwright documentation

    Microsoft

    Canonical API, locator, fixture, browser, and test-runner behavior.

  2. 02
    Playwright best practices

    Microsoft

    Official guidance for resilient tests, isolation, and user-facing locators.

  3. 03
    WebDriver standard

    W3C

    The browser automation protocol specification used by major automation stacks.

FAQ / QUICK ANSWERS

Questions testers ask

What does the Playwright --shard=2/4 option mean?

It tells the runner to execute the second partition from a total of four partitions. Every CI job must use the same total and a unique one-based shard index to cover the intended inventory.

Why does fullyParallel improve shard balance?

With fullyParallel enabled, Playwright can distribute individual tests across shards. Without it, distribution uses file-level granularity, so uneven file sizes can leave one shard with much more work.

Why use the blob reporter on sharded jobs?

Blob reports retain test results and attachments in a format designed for later merging. They let a downstream job generate one HTML, list, or other supported report from all shard outputs.

Should the report merge job run when a shard fails?

Yes, provided the workflow was not cancelled. Failed shards contain the most valuable errors, traces, and screenshots, so artifact upload and merge steps should not be gated on test success.

Can blob reports from different operating systems be merged?

They can, but the merge command may need an explicit merge configuration to disambiguate the test root. Keep source layout and configuration compatible, and tag genuinely different environments.