Prompt

Why do my Playwright tests pass locally but fail in CI?

Technology / Testing & QA1 observationLast seen Oct 27, 2026

Latest observation

Oct 27, 2026OpenAI APIWeb search: off

This is usually caused by differences between your local machine and CI, not by Playwright itself. The most common reasons are:

1) Timing / race conditions

Your tests may rely on UI appearing “fast enough” locally, but CI is slower.

  • Animations, network calls, rendering, or background jobs can take longer.
  • A test might assert before the app is actually ready.

Fixes:

  • Prefer Playwright’s built-in waiting: await expect(locator).toBeVisible()
  • Avoid waitForTimeout()
  • Wait for specific states/events instead of arbitrary delays

2) Environment differences

CI often runs with:

  • different CPU/memory limits
  • different OS/browser versions
  • headless mode
  • different locale/timezone/viewport

Fixes:

  • Make local and CI browser versions match
  • Set consistent viewport, locale, timezone, and permissions
  • Run tests in the same mode locally as CI (headless=true)

3) Flaky selectors

Selectors may work locally but fail in CI if the DOM changes slightly or renders differently.

Fixes:

  • Use stable locators like:
    • getByRole()
    • getByLabel()
    • getByTestId()
  • Avoid brittle CSS/XPath tied to layout or generated classes

4) Test data / backend state

CI might start with a clean database, different seeded data, or slower services.

Fixes:

  • Ensure test data is seeded consistently
  • Mock external APIs when possible
  • Reset database/state between tests

5) Parallelism issues

Tests may pass alone locally but fail in CI when running in parallel.

  • Shared accounts, files, ports, cookies, or backend state can collide.

Fixes:

  • Make tests independent
  • Avoid shared mutable state
  • Use isolated fixtures or unique test data per worker

6) Missing dependencies in CI

CI may not have everything your app needs:

  • fonts
  • system libraries
  • environment variables
  • secrets
  • browser dependencies

Fixes:

  • Check CI logs for missing env vars
  • Install Playwright browsers/deps properly
  • Verify the same .env values are available in CI

7) Headless-only issues

Some code behaves differently in headless browsers.

Fixes:

  • Reproduce locally with headless mode
  • Check if your app relies on focus, hover, or layout behavior that differs headless

8) Network or API instability

CI may hit slower or less reliable network endpoints.

Fixes:

  • Stub/mock network calls where possible
  • Add retries only as a last resort
  • Ensure external services are stable and reachable

Best debugging steps

  1. Run the same command locally as CI
  2. Enable Playwright trace/video/screenshots
  3. Inspect CI logs and trace viewer
  4. Compare env vars, browser versions, and viewport
  5. Look for flaky tests by rerunning

Example config to help debug:

use: {
  trace: 'on-first-retry',
  screenshot: 'only-on-failure',
  video: 'retain-on-failure',
}

If you want, I can help you diagnose the exact cause if you paste:

  • the failing test
  • your Playwright config
  • the CI error output

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.