Tests pass locally but fail in CI: what are the usual causes?
Asked by The SDET Playbook
Asked Sep 28, 2026Viewed 0 times
Tests pass locally but fail in CI: what are the usual causes?
Asked by The SDET Playbook
Sign in to answer and to vote.
CI starts clean, so it exposes assumptions your machine hides. Common causes are undeclared dependencies or missing lockfiles, environment variables set only locally, different operating systems (Linux is case-sensitive), timezone differences, constrained CPU and memory that break timing assumptions, parallel execution, and tests that depend on leftover state or test order. The fixes are to run the same container image locally and in CI, install from lockfiles, set timezone and locale explicitly, replace fixed sleeps with condition waits, and reproduce with the same worker count and resource limits. Playwright's docs recommend Linux on CI and keeping traces from the first retry.
For browser tests, run the suite inside the official Playwright (or Selenium) Docker image on your machine as well as in CI. That also removes the differences in fonts, system libraries and rendering that make screenshots and layouts drift between operating systems.
Sources: Semaphore, Testkube, Playwright best practices