API …
Dynamic & timing

Flaky root causes & retries

Why tests flake, how to fix each cause, a retry and quarantine checklist and a run-it-N-times simulator.

Practice tasks

  • Pick “Fixed sleep 2 s” and run 200 times; then compare with auto-wait: note both the pass rate and the average duration.
  • Explain why the “last response wins” race still fails after adding a sleep, and which strategy actually removes the flake.
  • Compute the chance that a suite of 20 independent tests, each 98 % reliable, is green; compare with the simulator’s suite estimate.
  • Work through the checklist on your own project and write down which step you skipped.
  • Add retries: 2 to playwright.config, run a flaky spec and find the “flaky” label in the HTML report.
  • Use test.fixme() to quarantine one scenario from the lab pages and link it to a ticket id in the title.

More Dynamic & timing practice