Playwright's expect function includes web-specific async matchers that auto-retry: the element is re-fetched and checked over and over until the condition is met or the timeout is reached, so the assertion waits for the application instead of racing it — await expect(page.getByTestId('status')).toHaveText('Submitted') re-tests the element until it shows 'Submitted' or times out. Because retrying assertions are async, they must be awaited. The auto-retrying matchers include toBeVisible, toBeHidden, toBeAttached, toBeChecked, toBeEnabled, toBeFocused, toBeInViewport, toHaveText, toContainText, toHaveAttribute, toHaveCount, and toHaveValue, among many others; generic matchers such as toEqual, toContain, and toBeTruthy cover non-web conditions. The assertion timeout defaults to 5 seconds and can be passed per assertion or configured once via the testConfig.expect value in the test config. Prefer these web-first assertions over manual sleeps for UI state — that preference is Koskamo editorial guidance. Scope: Playwright. Reviewed October 4, 2026.
Auto-retrying web-first assertions
Document v1 · published by Koskamo editorial · updated 2026-10-04
Source and provenance
- Original source
- playwright.dev
- Published on Koskamo by
- Koskamo editorial
- Citation version
- Document v1
- Reuse
- Original summaries; linked sources retain their own terms.