- All playbooks
- Wait for the state transition before asserting
Wait for the state transition before asserting
Synchronize with the event that makes the assertion true, so the test stops needing reruns.
Company examples
How Uber used this technique
Read what Uber changed and follow the original sources.
Wait for the state transition before asserting
A SubmitQueue integration test checked consumer lag right after acknowledging a delivery, while the queue updated its watermark on the next poll tick. The fix waits for a delivery-check signal before reading lag. OPT48 is adapted to one flaky test.
The author ran the test 50 times locally, all passing. Source
- Use it when
- A test observes asynchronous state before the operation that updates it completes.
- Before applying it
- Wait for the specific event under test with a bounded timeout, keep the assertions, and confirm the signal comes from the operation being tested.
Company Playbooks
- Read Anthropic’s playbookRun only affected tests
- Read DoorDash’s playbookRun build and test in parallel, sharded across CI agents
- Read Linear’s playbookBenchmark the same job on faster hardware
- Read Mastra’s playbookStarSling runners for the slowest test workflow
- Read OpenAI’s playbookRank CI fixes by the minutes they save
- Read Ramp’s playbookMove a CPU-bound test suite to a faster CPU
- Read Shopify’s playbookLet an agent iterate against one CI metric
- Read Spotify’s playbookBuild arm64 on native arm64 runners
- Read Stripe’s playbookRun only the tests a change can reach
- Read Uber’s playbookBuild the merge-queue speculations most likely to be needed