Fix the flaky test, don't retry it
October 26, 2026 · How we work
A test that passes nine times and fails once is the easiest thing in the world to ignore. Run it again, it goes green, merge. world95 has a rule against that, written into the file every session reads first: a flaky test gets fixed (wait for a condition, time it in game time), never retried until it passes. Here's why, with real cases.
Sometimes the test is right
Our multiplayer test has two players, Bob and Alice. Bob watches Alice walk across town and checks that she never stops between steps. When it ran alone, it passed. In the full run, with other tests busy beside it, it failed now and then: Bob saw Alice stand still for about a fifth of a second.
The easy story was "the machine was busy." The worker on it didn't stop there. It made the test write down what Bob saw, frame by frame: where Alice was drawn, her newest step, and both games' clocks. That record showed the real cause. Under load, the two games' clocks ran at slightly different speeds, so Alice's steps reached Bob up to 0.42 seconds apart. Bob's game only kept enough of her walk in hand to cover a step about 0.13 seconds late. Past that, it stopped her and waited.
That isn't a test problem. It's what a player on a slow phone connection would see: other people stopping and starting as they walk. So the fix went into the game. Other players now walk on smoothly through a step up to 0.35 seconds late, a little further behind where they really are. A retry would have hidden a bug players would have felt.
When you can't see why a test fails, make it write down what it saw.
Wait for a condition, not a delay
Most flaky tests are racing the game. Three from the last few days:
- The menu that wasn't drawn yet. A test opened a menu, saw the server's answer arrive, and read the menu's rows straight away. On a busy machine the game hadn't drawn them yet, so the test saw "Loading…". Now it waits until the row it's looking for is actually on screen.
- The half-drawn frame. The game draws each frame in bands, then the players on top. A test that reads the screen to find where to click could read it halfway, find grass where a player was about to be drawn, and click on her instead. Now it reads only between frames.
- The message that wasn't new. A test counted the messages a player's game sent, and the game's own clock checks got counted too. Other tests already left those out. Now this one does as well.
None of these is fixed by waiting longer. A longer pause just makes the race rarer and the test slower. Waiting for the thing you need fixes it for good.
Time it in the game's own clock
Some checks are about time itself, and a busy machine stretches time.
- A tap that became a long press. A test tapped the screen by sending "finger down" then "finger up." On a slow machine the second event arrived so late that the game read the tap as a long press. Now each event carries its own time, 50 ms apart, whatever the machine is doing.
- A double jump that was too slow. Pressing jump twice within 0.35 seconds of game time starts flying. The test pressed, waited a couple of frames and pressed again, but under load those waits took longer than 0.35 seconds. Now the test holds the game's clock during the double press and steps it one update at a time, so the two presses are always a few frames apart.
If the game measures something in its own time, the test should too.
A wait that gives up should say so
An easy mistake: a test waits for something, the wait times out quietly, and the test carries on. Three steps later something unrelated fails, and the error points at the wrong thing. Our tests now make a wait that gives up fail on the spot, with what the game had at that moment. The failure then says what was actually wrong.
And one kind of wait never works at all. In the browser tool we use, "wait until this is true" given an async check doesn't wait. It counts as done straight away. So the check that runs before every test run (see One command runs every test) fails if any test is written that way.
Make your own tests this steady
- Never retry until green. A second failure is real, and so was the first.
- Run your tests under load. Side by side, a few at a time. It finds races a quiet machine hides.
- Wait for a condition. The row is drawn, the message came, the frame is finished. Not "two seconds."
- Use the program's own clock for anything about time.
- Make waits fail loudly, with what they saw.
- When you're stuck, record. Have the test write down what it saw, frame by frame, and read it.
- Ask if the test is right. Sometimes the flaky test found a real bug.