Prueba rápida
Guess first, no penalty. An AI-written test pauses with page.waitForTimeout(3000) before checking the total. It fails about once a week in CI. What's the best fix?
Wait for the condition, not the clock
A flaky test passes and fails on the same code. CI (continuous integration, the system that runs your tests on every change) is where flaky tests hurt most. AI tools often add fixed pauses, because pauses look like they fix timing problems.
Playwright has waiting built in. Its actionability docs say it "auto-waits for all the relevant checks to pass and only then performs the requested action", such as the element being visible and enabled. Its assertion docs describe auto-retrying assertions that retry until they pass or time out. By default, the timeout for assertions is 5 seconds. The docs also warn that "using non-retrying assertions can lead to a flaky test."
So the fix is to delete the pause and await an auto-retrying assertion on the thing you're waiting for.
A worked example
Before (flaky):
await page.getByRole('button', { name: 'Apply' }).click();
await page.waitForTimeout(3000);
expect(await page.getByTestId('cart-total').textContent()).toBe('$45.00');
After:
await page.getByRole('button', { name: 'Apply' }).click();
await expect(page.getByTestId('cart-total')).toHaveText('$45.00');
Completa los espacios
Fill the gaps.
Fix
Delete and use , which .
Try it
Tus pasos, unos 1 minutos
- 1.Search your test suite for waitForTimeout and replace one with an auto-retrying assertion.1 min
Your AI test kit is now complete. Keep it next to your test plan:
1. Test cases from a story: case types, a table, and "list unclear criteria".
2. Boundaries: just below, at the minimum, at the maximum, just above.
3. Make every new test fail once by changing its expected value.
4. Expected values come from the rule, never from the code.
5. No fixed pauses: wait with auto-retrying assertions.