Frontend & browser·Testing a user interface
you deleted the `sleep(500)` because the runner already retries the assertion until it passes or times out.
Auto-waiting
Also calledretry-ability, implicit wait
A test runner retrying a query or assertion until it succeeds or a timeout expires, instead of asserting once against an asynchronous interface. It is what removed fixed sleeps from browser testing, and fixed sleeps are simultaneously the main cause of flakiness and of slow suites. It cannot rescue an assertion about something that should not appear, which still needs an explicit wait for a stable state.