Condition-Based Waiting
Condition-Based Waiting
Overview
Flaky tests often guess at timing with arbitrary delays. This creates race conditions where tests pass on fast machines but fail under load or in CI.
Core principle: Wait for the actual condition you care about, not a guess about how long it takes.
When to Use
digraph when_to_use {
"Test uses setTimeout/sleep?" [shape=diamond];
"Testing timing behavior?" [shape=diamond];
"Document WHY timeout needed" [shape=box];
"Use condition-based waiting" [shape=box];
"Test uses setTimeout/sleep?" -> "Testing timing behavior?" [label="yes"];
"Testing timing behavior?" -> "Document WHY timeout needed" [label="yes"];
More from obra/superpowers-skills
getting started with skills
Skills wiki intro - mandatory workflows, search tool, brainstorming triggers
291test-driven development (tdd)
Write the test first, watch it fail, write minimal code to pass
10brainstorming ideas into designs
Interactive idea refinement using Socratic method to develop fully-formed designs
10writing plans
Create detailed implementation plans with bite-sized tasks for engineers with zero codebase context
8systematic debugging
Four-phase debugging framework that ensures root cause investigation before attempting fixes. Never jump to solutions.
8code review reception
Receive and act on code review feedback with technical rigor, not performative agreement or blind implementation
7