4 months ago

Laravel Dusk - SweetAlert - AssertDialog

Posted 4 months ago by sirhxalot

Hi Folks!

I would like to write a Laravel Dusk Test in Laravel 5.8 in order to test dialogs.

So far I have made a Vue Component that contains a button. When the button is clicked it sends a post request to a controller method. If we had a failure e.g. invalid input (validation) a 422 stauts code will be thrown and a sweet alert modal pop ups.

Everything is working as expected. However I wanted to create a Dusk test to check if the modal has been opened so I tried:

        $this->browse(function (Browser $browser) use ($user) {
                    ->type('@first_name', '')
                    ->assertDialogOpened("An error occurred we couldn't proceed. Please checkout your form inputs.")

The test seems to be fine since the modal will be opened. However it respond with: Facebook\WebDriver\Exception\TimeOutException: Waited 1 seconds for dialog.

When I open the screenshot in Browser/screenshots/ I see the message!

Besides the deleteAllCookies() has been added just for testing purposes it works neither with or without the code.

Does somebody has a clue?

Thank you in advance.

Please sign in or create an account to participate in this conversation.