THE REPLACEQA BLOG

Playwright passes locally but fails in CI: a diagnosis checklist

Reproduce CI-only Playwright failures by comparing environments, data, browser versions and worker counts before changing retries or timeouts.

When Playwright passes locally but fails in CI, reproduce the failing conditions before changing the test. Compare the exact source revision, browser installation, application build, starting data and concurrency. A slower runner can expose a defect, but “CI is slow” does not explain which requirement failed.

A Reddit discussion about CI-only failures raised fonts, timezones, leftover sessions and parallel workers. Those are useful investigation leads, not evidence that any one explains your failure. This checklist turns them into experiments. Documentation was checked on November 18, 2026; the examples below are diagnostic configurations, not benchmark results.

Save a comparable pair of runs

Keep the failed CI trace, output, commit identifier and application deployment identifier. Run the same test locally at that revision. Avoid comparing a CI failure from yesterday with a local pass against today's backend.

Create a short record for each execution:

VariableRecord explicitlyWhy it changes the experiment
ApplicationBuild, origin, feature flagsDifferent behavior can look like test instability
Test runtimeNode, package lock, Playwright and browser versionsA different browser or dependency can change behavior
Browser contextViewport, locale, timezone, permissionsFormatting and responsive navigation may differ
DataAccount, tenant, record IDs, seed versionA warm local database can hide a missing prerequisite
ExecutionWorkers, shard, retry numberContention can appear only in the full suite

Do not print secret values to prove they exist. Validate that required variables are present and inspect the resulting behavior, such as reaching the intended environment with the expected account.

Establish a clean single-worker baseline

Run the repository's locked installation and the browser needed by the failing project. The official CI guide documents dependency installation and recommends one worker as a stability-first CI starting point.

npm ci
npx playwright install --with-deps chromium
npx playwright test tests/catalog.spec.ts --project=chromium --workers=1 --retries=0

Replace the file and project with names from your suite. Use the same command in both environments. A single-worker pass is evidence to investigate concurrency; it is not proof that the test should permanently run alone.

For a temporary diagnostic configuration, merge these values into your existing settings:

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

export default defineConfig({
  workers: 1,
  retries: 0,
  globalTimeout: 10 * 60 * 1000,
  use: {
    viewport: { width: 1280, height: 800 },
    locale: 'en-US',
    timezoneId: 'UTC',
    trace: 'retain-on-failure',
    screenshot: 'only-on-failure',
  },
});

Ten minutes is an example investigation budget, not a recommended limit for every suite. Leave enough time in the outer CI job to upload artifacts after Playwright stops. Preserve your application startup, base URL and projects when merging the fragment.

Find the first meaningful divergence

Open the failed trace and inspect the last state that matches the intended journey. Our trace investigation guide explains how to connect a failed action with page and network evidence.

Suppose the test cannot click “Templates.” If CI shows a hamburger menu while local shows desktop navigation, compare viewport settings. If the menu is present but a permission dialog covers it, inspect the permission setup. If the click succeeds but the result never arrives, compare the actual API response and fixture record.

Investigate transport failures and HTTP failures separately. A completed request returning 403 is different from a connection that never completed. Check whether CI's origin is permitted by a third-party integration, whether a proxy changes the request, and whether the test points at the expected service. Do not compensate for an authorization failure with a longer timeout.

Change one variable at a time

A useful progression is: clean local run, same run inside the CI image, then the same image on CI. The Playwright Docker documentation explains that its image supplies browsers and system dependencies; your project still needs its own package installation. Match the image version to the Playwright package used by the suite.

Even identical images do not equal identical resources or networks. Measure CPU or memory pressure when increasing workers. Look for multiple tests editing the same account or consuming the same export quota. Restore concurrency gradually after isolating backend data.

For a suspected timing issue, replace a snapshot read of current state with an assertion on the required eventual outcome. Keep the allowed wait tied to the application's service expectation. A slow page that violates that expectation may be a real regression.

Verify the explanation survives another run

Record the hypothesis, the single change and the observed outcome. Repeat in both environments with the original failure evidence retained. Then run the full affected group: an isolated test can miss interference from its neighbors.

Do not declare success solely because a retry is green. The retry guide explains how to retain the distinction between clean passes and recovered failures. If the root cause remains unknown, say so in the issue and give it an owner.

Once the journey is reliable, the monitoring guide shows how to run it repeatedly and retain evidence. ReplaceQA's closed beta can help discover public journeys and generate Playwright source with validation evidence. Request beta access if that preparation workflow fits; recurring execution remains separate.

Keep checking your important customer journeys.

Explore ReplaceQA ↗