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