Skip to content

Fix Playwright wait methods not executing commands - #256

Open
asllanmaciel wants to merge 2 commits into
pestphp:5.xfrom
asllanmaciel:fix/1892-wait-methods-consume-generator
Open

asllanmaciel wants to merge 2 commits into
pestphp:5.xfrom
asllanmaciel:fix/1892-wait-methods-consume-generator

Conversation

@asllanmaciel

@asllanmaciel asllanmaciel commented Sep 9, 2026 •

Copy link
Copy Markdown

Summary

Consumes the Client::execute() generator in the page wait methods so their Playwright commands are actually sent.

Client::execute() is lazy because it returns a Generator; calling it and discarding the result does not execute the websocket send. waitForLoadState(), waitForFunction(), and waitForURL() were therefore silent no-ops.

This patch routes those calls through the existing processVoidResponse() helper, which consumes the generator, and adds regression coverage asserting that each wait method sends the expected Playwright message.

Fixes pestphp/pest#1892.

Test isolation follow-up

The regression tests stub the singleton Client websocket connection. A follow-up commit now clears that stub in afterEach() so the fake connection cannot leak into later tests in the same process and interfere with a real connectTo() call.

Validation

  • regression coverage for waitForLoadState(), waitForFunction(), and waitForURL() is present on the current head;
  • focused wait-method suite on PHP 8.4: 3 tests / 11 assertions - PASS;
  • Composer quality stages reached before the browser runtime suite - Rector, style checks, profanity/type-coverage checks, and PHPStan - passed in the validation environment;
  • the broader browser test run could not complete there because the Playwright browser/runtime was not installed, so no full-suite PASS is claimed;
  • current GitHub Actions run for the external-fork head (Tests #1202) is action_required before jobs execute; this is an authorization gate, not a test failure;
  • git diff --check is clean.

The implementation remains intentionally narrow: three existing wait methods now consume the response exactly like the other void Playwright operations, and the tests restore singleton state after each case.

AI assistance was used to help investigate, prepare, and review the patch. I reviewed the final diff and validation evidence and take responsibility for the contribution.

@asllanmaciel
asllanmaciel force-pushed the fix/1892-wait-methods-consume-generator branch from 63830bf to f62e6a5 Compare September 14, 2026 16:14
@Sagmedjo

Sagmedjo commented Oct 5, 2026

Copy link
Copy Markdown

Confirming on 5.0.1: $page->page()->waitForFunction('false') returns after 0.00 s, and so does a condition that only becomes true later. The request is never sent, because the Client::execute() generator is never consumed. waitForLoadState() has the same shape. Until this is merged we wait by evaluating an async polling promise through Page::evaluate(), which consumes its generator.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[pest-plugin-browser] Page::waitForLoadState() never sends its message — waitForEvent() is a silent no-op

2 participants