feat(playwright): configurable default timeout and retrying visibility assertions - #208
Conversation
…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
c7ba979 to
2c31e50
Compare
|
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 |
|
Hmm, my idea for this feature was: every assertion/action "waits" until the selector is available. The wait until's would basically no longer be required because every selector would do this. |
|
That is a better shape than what I did, and the good news is that it is a smaller change than doing it assertion by assertion. Every selector-based assertion on Two things I would rather have your call on before reshaping this PR: Polling the Mink assert, or native Negative assertions get slow when they genuinely fail. Happy to rework this PR into the |
|
Yes, #211 covers everything this PR was after, and the auto wait is in the right place. Thanks for taking it the whole way rather than settling for the two assertions I had reached. One gap I think is worth a look, since
The new tests cover actions, assertions, negative assertions and the timeout, but none of them exercise those two, so I may well be reading it wrong. If it holds, folding both into Everything else lines up: This one is yours to close whenever suits you. |
Fixes #199
Both points from the issue:
default_timeoutoption (ms) onPlaywrightBrowser, wired to aBROWSER_DEFAULT_TIMEOUTenv var inHasBrowser. It is applied viapage->setDefaultTimeout(), so it covers actions and thewaitUntil*()methods. When not set, Playwright's 30 second default stays as is.assertVisible()/assertNotVisible()now poll client-side (100ms interval, 5 second cap) throughPlaywright\Testing\Expect, the same shape as Use auto-waiting locator assertions playwright-php/playwright-symfony#35. Failure messages are unchanged, and both still go throughsession()->assert()first so exception-page detection keeps working.Tests: the retry is proven against
#timeout-box(visible 500ms after load, asserted without anywaitUntil*()), 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.