Skip to content

QuizNot attempted

Avoiding flakiness

Which practice makes Playwright tests LESS flaky?
1–4 to choose, Enter to submit
Show answer & explanation

Correct answer:

  • Web-first assertions like await expect(page.getByRole('button', { name: 'Pay' })).toBeEnabled(), which auto-wait
  • Web-first assertions (await expect(locator).toBeEnabled()) retry until the condition holds, so they wait exactly as long as needed.
  • Not waitForTimeout(3000): fixed sleeps are slow when the app is fast and still flaky when it is slow.
  • Not generated class names: they change on every build.
  • Not shared mutating login state: tests couple to each other's side effects
  • use storageState per test and isolated data.