Delivery & cloudInterview preparation
Intermediate·Scenario·2 min read

Tests pass locally but fail in CI. Why?

Practice this question

Definition:

A local/CI mismatch means the test depends on something that differs between environments. Common differences include runtime versions, installed files, operating-system behavior, time, service availability or test order. Reproducing the CI command in a clean setup exposes these hidden assumptions.

Key points:

  • Compare runtime versions, lockfiles, environment variables and working directories.

  • Check timezone, case-sensitive filenames, test ordering and unavailable services.

  • Reproduce the CI command in a clean environment before changing the test.

  • Use the lockfile and avoid depending on locally generated files that are not committed or built by the pipeline.

Interview point:

  • Do not simply retry or skip the failing test; determine whether it found a real bug, a missing dependency or unstable test design.
Adapted from 09_TESTING_GIT_DOCKER_CLOUD.md · “Tests pass locally but fail in CI. Why?”. Code examples are study fragments. Difficulty and core labels are editorial estimates; version-specific behavior should be checked against your project.