API …
Dynamic & timing

Flaky network & async

Failing-then-succeeding APIs, race conditions, out-of-order results, late options and flapping connections.

Practice tasks

  • Call the API with N = 2 and write a retry loop (or expect(...).toPass({ intervals: [250, 500, 1000] })) that is green on attempt 3.
  • Run the 20-call batch at 30 % and compute the failure ratio; then decide where a retry belongs: the test or the client under test.
  • Reproduce the race condition by typing “play” with locator.pressSequentially(), find the bug in the arrival log and verify the fix checkbox.
  • Wait for each panel by name (never by arrival order) with Promise.all of locator.waitFor() calls.
  • Select “Large” after the options load with locator.selectOption('large') and compare with a Selenium WebDriverWait on option count.
  • Use context.setOffline(true) and page.route('**/api/products*', r => r.abort()) to assert the offline error state.
  • Assert data-state on the output box moves idle → loading → ok using expect(locator).toHaveAttribute and expect.poll().

More Dynamic & timing practice