Skip to content

feat(playwright): configurable default timeout and retrying visibility assertions - #208

Open
Amoifr wants to merge 1 commit into
zenstruck:1.xfrom
Amoifr:feat-199-playwright-timeout-retrying-assertions
Open

feat(playwright): configurable default timeout and retrying visibility assertions#208
Amoifr wants to merge 1 commit into
zenstruck:1.xfrom
Amoifr:feat-199-playwright-timeout-retrying-assertions

Conversation

@Amoifr

@Amoifr Amoifr commented Aug 25, 2026

Copy link
Copy Markdown

Fixes #199

Both points from the issue:

  • Configurable timeout: a default_timeout option (ms) on PlaywrightBrowser, wired to a BROWSER_DEFAULT_TIMEOUT env var in HasBrowser. It is applied via page->setDefaultTimeout(), so it covers actions and the waitUntil*() methods. When not set, Playwright's 30 second default stays as is.
  • Retrying assertions: assertVisible()/assertNotVisible() now poll client-side (100ms interval, 5 second cap) through Playwright\Testing\Expect, the same shape as Use auto-waiting locator assertions playwright-php/playwright-symfony#35. Failure messages are unchanged, and both still go through session()->assert() first so exception-page detection keeps working.

Tests: the retry is proven against #timeout-box (visible 500ms after load, asserted without any waitUntil*()), and the timeout by asserting a 250ms configured wait fails well under Playwright's 30s default.

As noted in the issue this makes waitUntilVisible()/waitUntilNotVisible() mostly redundant; I left them untouched, happy to deprecate them here or in a follow-up if you prefer.

…y assertions

Two changes from the issue:

- a default_timeout option (BROWSER_DEFAULT_TIMEOUT env var), applied
  as the page's default timeout: it covers actions and the waitUntil*()
  methods, which otherwise use Playwright's 30 second default.
- assertVisible()/assertNotVisible() now retry client-side (100ms poll,
  5 second cap) instead of being one-shot checks, using the same shape
  as playwright-symfony's locator expectations. Failure messages are
  unchanged.

Fixes zenstruck#199
@Amoifr
Amoifr force-pushed the feat-199-playwright-timeout-retrying-assertions branch from c7ba979 to 2c31e50 Compare August 25, 2026 09:42
@Amoifr

Amoifr commented Aug 25, 2026

Copy link
Copy Markdown
Author

The two red jobs on the first run were a pre-existing race, not related to this diff: the file-saving tests share the same var/browser/source/source.txt under paratest --functional, so can_save_formatted_json_source and can_save_source_when_exception each read the other's output. I opened #209 with a fix (unique filename per save). Re-triggered CI here in the meantime.

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