Skip to main content
InterviewHubPRO
Section Overview
Q13

Question 13 of 50

Part 1: Basic & Foundational Concepts (Junior / Entry-Level)

26%
Software Testing & QA (50 Qs)•Part 1: Basic & Foundational Concepts (Junior / Entry-Level)

What makes a test "flaky", and how do you systematically quarantine and fix it?

junior Levelsoftware-testingBasic

In Simple Words: A flaky test passes or fails unpredictably without any changes to the underlying code.

  • Primary Causes:
    1. Hardcoded sleeps (await sleep(2000) instead of polling or waiting for network events).
    2. Race conditions and non-deterministic concurrency.
    3. Shared global state or test execution order dependencies.
    4. Timezone, date, or locale dependencies (new Date()).
  • Remediation:
    1. Quarantine: Move flaky tests into a separate non-blocking CI job so they don't block PR merges.
    2. Run with Chaos: Execute the test 100 times in a loop locally with simulated network latency to reproduce the race condition.
    3. Replace arbitrary timers with deterministic condition polling.