Appearance
date: 2026-06-07 tags: [testing, pest, browser, internals] status: active graduated_to:
pest-plugin-browser pending-page proxy returns the value for value-methods, $this for fluent ones
Symptom — Wanted to drive both assertNoSmoke() (fluent) and script() (returns a value) off one expect(visit('/')) subject — where the subject is an un-resolved PendingAwaitablePage, not a Webpage. Unclear whether script() would return the scraped value through that proxy.
Root cause — PendingAwaitablePage::__call forwards to AwaitableWebpage::__call, which runs the method on a fresh Webpage and returns $result === $webpage ? $this : $result (AwaitableWebpage.php). So a method returning the page (assertX) keeps the chain fluent, while a method returning a value (script()) returns that value — through the pending proxy, which lazily boots and memoises the page on first call.
Fix — expect(visit('/'))->toHaveNoSmoke()->toRenderPlannedDay(...) works: the first extension's assertNoSmoke() boots + checks the page, the second's script() scrapes the same memoised page and returns the array — no need to resolve to Webpage first. See tests/Pest.php.
Guard — The two expect() extensions in tests/Pest.php. Plugin-internal behaviour — re-verify on a pest-plugin-browser major bump. Related: [[2026-06-07-pest-browser-no-assert-see-in-order]].