fix: reorder retry patterns to prioritize simpler assertions

Amp-Thread-ID: https://ampcode.com/threads/T-019c2f99-6c3b-701e-8f90-4f897ecf85d8
This commit is contained in:
bymyself
2026-02-05 13:01:25 -08:00
parent 918c6c3687
commit 18079644a2

View File

@@ -77,14 +77,17 @@ test.describe('Feature', { tag: ['@screenshot', '@canvas'] }, () => {
**Never use `waitForTimeout`** - it's always wrong.
| Pattern | Use Case |
| ------------------------ | -------------------------------------- |
| `expect.poll()` | Single value polling |
| `expect().toPass()` | Multiple assertions that must all pass |
| Auto-retrying assertions | `toBeVisible()`, `toHaveText()`, etc. |
| Pattern | Use Case |
| ------------------------ | ---------------------------------------------------- |
| Auto-retrying assertions | `toBeVisible()`, `toHaveText()`, etc. (prefer these) |
| `expect.poll()` | Single value polling |
| `expect().toPass()` | Multiple assertions that must all pass |
```typescript
// Single value
// Prefer auto-retrying assertions when possible
await expect(node).toBeVisible()
// Single value polling
await expect.poll(() => widget.getValue(), { timeout: 2000 }).toBe(100)
// Multiple conditions