Repository navigation
fix: retain javascript errors and console logs across navigation - #317
Conversation
Signed-off-by: Helmi Pradita <helmipraditaa@gmail.com>
7a2cf18 to
bb8a1fc
Compare
|
Please preserve errors across origin changes in the same tab. I reproduced one recorded error becoming zero after navigating from |
….name sessionStorage is origin-scoped, so navigating 127.0.0.1 -> localhost on the same server dropped recorded errors/logs. Carry the payload in window.name (namespaced), which persists across same-tab navigations regardless of origin. Add cross-origin regression tests for both jsErrors and consoleLogs.
|
Thanks @MrPunyapal — addressed in
I verified the persistence mechanism (payload survives an origin change; unrelated |
|
Please avoid storing the collector in application-owned |
|
Hi @MrPunyapal, addressed in
|
|
thanks |
Summary
Fixes pestphp/pest#2026.
When performing full-page navigations in browser tests (via
$page->navigate(), clicking links, or submitting forms), the browser tears down the previouswindowobject and creates a new one.InitScript.phpruns on every document initialization and previously resetwindow.__pestBrowserto empty arrays:As a result, any JavaScript errors or console logs from earlier pages in that same browser tab session were lost before
assertNoJavaScriptErrors()orassertNoConsoleLogs()ran on the subsequent page.Solution
src/Playwright/InitScript.php, persistjsErrorsandconsoleLogsusingsessionStoragein a defensivetry / catchblock.sessionStoragenatively persists across full-page navigations within the same browser tab and remains isolated to that page session.sessionStorage.AssertNoJavaScriptErrorsTest.phpandAssertNoConsoleLogsTest.phpasserting that errors and logs originating from earlier pages remain detectable after$page->navigate().