Created
July 15, 2020 18:49
-
-
Save jhoff/4b83b7dc39ffc3e8c3c7c808c2dedd0c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use Laravel\Dusk\Browser; | |
Browser::macro('waitUntilWire', function ($component, $key, $value, $seconds = null) { | |
return $this->waitUsing($seconds, 100, function () use ($component, $key, $value) { | |
return $value == $this->wireAttribute($component, $key); | |
}); | |
}); | |
Browser::macro('waitUntilWireNot', function ($component, $key, $value, $seconds = null) { | |
return $this->waitUsing($seconds, 100, function () use ($component, $key, $value) { | |
return $value != $this->wireAttribute($component, $key); | |
}); | |
}); | |
Browser::macro('wireAttribute', function ($component, $key) { | |
return $this->driver->executeScript(' | |
return (component = window._.first(window._.filter(window.livewire.components.components(), {name: "' . $component . '"}))) ? component.data["' . $key . '"] : undefined; | |
'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment