Skip to content

Instantly share code, notes, and snippets.

@hardevine
Forked from calebporzio/wait_for_reload.php
Created August 12, 2020 16:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hardevine/8280fabf7f3c9594efb467f5ebdd61b2 to your computer and use it in GitHub Desktop.
Save hardevine/8280fabf7f3c9594efb467f5ebdd61b2 to your computer and use it in GitHub Desktop.
Simple Laravel Dusk macro that waits for a page change
<?php
// Define in some ServiceProvider
Browser::macro('waitForReload', function () {
$this->script("window.duskPageIsStale = {}");
return $this->waitUntil("return typeof window.duskPageIsStale === 'undefined';");
});
// Usage:
->click('button')
->waitForReload()
->assertSee('Something on new page')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment