Skip to the editor

The save test is flaky

Waiting & flakiness · level 4 of 5 · PipelineHQ

A fixed sleep is a bet on how long the app takes. Wait for the result you expect, and the flakiness disappears.

The problem

This test creates a contact and checks the toast, and it passes, sometimes. Saving takes around 700ms, but the test only sleeps 400ms before asserting, so on a slow run the toast is not there yet and the test goes red.

Remove the sleep. Let the assertion wait for the toast instead, it retries until the toast appears, however long the save takes.

Debug the flaky test

This suite is unreliable. Run it a few times to see it fail sometimes, then make it stable without using sleeps or relying on the order tests run in.

Done when

  • Green three runs in a row.
  • No fixed sleeps, wait for the toast itself.

What this test covers

  • No confirmation toast after saving

We break nothing here. Grading runs the suite three times and in reverse order.

Loading the editor…