Skip to content

feat(playwright): auto-wait for actions and assertions - #211

Open
kbond wants to merge 1 commit into
zenstruck:1.xfrom
kbond:playwright-auto-wait
Open

feat(playwright): auto-wait for actions and assertions#211
kbond wants to merge 1 commit into
zenstruck:1.xfrom
kbond:playwright-auto-wait

Conversation

@kbond

@kbond kbond commented Aug 30, 2026

Copy link
Copy Markdown
Member

Actions and assertions now wait for the page to catch up, so waitUntil*() is rarely needed. Clicking or filling waits for the element to appear, assertions retry until they pass, and "not" assertions pass as soon as they hold. Everything gives up after BROWSER_DEFAULT_TIMEOUT (2 second default) and fails as before.

This helps most with Turbo, where visits, frames and streams all update the page without a navigation to wait on - assertions following a Turbo-driven click, or a stream broadcast that arrives on its own, simply wait for the new content to land.

Only PlaywrightBrowser is affected - KernelBrowser and PantherBrowser behave exactly as they did. Page loads keep Playwright's 30 second limit, since a cold kernel boot is far slower than anything an assertion should wait for.

The trade is that an assertion destined to fail can only be reported once the timeout expires, so failures cost 2 seconds (default) instead of returning instantly. timeout() adjusts it per test.

Closes #199. Supersedes #208.

Actions wait for their element to appear and assertions retry until they pass, so `waitUntil*()` is rarely needed. Whole operations are retried rather than individual lookups: a waiting lookup would invert the "not" assertions and make every speculative miss cost the full timeout.

Non-playwright drivers get a zero budget, which is one attempt and no sleep.
@kbond

kbond commented Aug 30, 2026

Copy link
Copy Markdown
Member Author

@Amoifr what do you think of this as an alternative to #208?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

PlaywrightBrowser: configurable timeout and waiting assertions

1 participant