Prompt

flaky ui tests in ci

Technology / Testing & QA1 observationLast seen Oct 16, 2026

Latest observation

Oct 16, 2026OpenAI APIWeb search: off

Flaky UI tests in CI are usually caused by timing, environment differences, shared state, or test/data instability. The key is to make failures reproducible, then attack the root cause—not just retry forever.

Common causes

  • Async timing issues: element not ready yet, animations still running, network calls unresolved
  • Race conditions: test actions happen faster/slower in CI than locally
  • Selector instability: brittle CSS/XPath selectors, dynamic IDs
  • Shared state: tests depend on prior tests, leftover cookies/localStorage/db state
  • Environment differences: headless browser behavior, viewport, CPU throttling, timezone/locale
  • External dependencies: real APIs, third-party services, unstable test data
  • Test pollution: parallel tests writing to same user/account/data

How to stabilize them

  • Prefer stable selectors like data-testid
  • Wait for specific conditions, not arbitrary sleeps
  • Mock or stub network calls where possible
  • Reset state before each test:
    • cookies/localStorage/sessionStorage
    • DB/test fixtures
    • user/account data
  • Make tests independent and idempotent
  • Use consistent CI config:
    • viewport
    • timezone
    • locale
    • browser version
  • Avoid relying on exact animation timing; disable animations in tests
  • Run tests in isolation to find order dependencies
  • Capture artifacts on failure:
    • screenshots
    • video
    • console logs
    • network logs
    • DOM snapshot

Debugging strategy

  1. Rerun the failed test alone
  2. Run it repeatedly (e.g., 20–50 times) to confirm flakiness
  3. Compare local vs CI environment
  4. Look at the first point of divergence in logs/artifacts
  5. Remove arbitrary waits and replace with explicit waits
  6. Reduce external dependencies with mocks/fixtures
  7. Check for hidden shared state

CI-specific improvements

  • Increase browser startup stability and resource limits
  • Use dedicated test containers/VMs
  • Serialize tests that touch shared resources
  • Quarantine known flaky tests temporarily, but track and fix them
  • Add automatic retry only as a short-term mitigation

Good rule of thumb

If a UI test fails intermittently, assume:

  • it’s waiting on something it doesn’t explicitly know about, or
  • it’s depending on state it doesn’t fully control.

If you want, I can help you with:

  • a flaky test debugging checklist
  • Playwright/Cypress/Selenium-specific fixes
  • a strategy to isolate and reproduce a CI-only UI flake

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.