magarrent-6561770's avatar

Handle 500 http errors from Laravel Dusk

Hey! I'm starting using Laravel Dusk.

If I visit this url:

$user = User::factory()->create();

        $this->browse(function (Browser $browser) use ($user) {

            $browser->loginAs($user)
                ->visit(route('sample'));

        });

The server returns a http 500 error, but the Dusk test passed well.

How can I handle this and avoid passing tests if the request is a 500 or similar?

0 likes
2 replies
magarrent-6561770's avatar
Level 1

Did not see any native solution.

I've just created my own macro:

Browser::macro('assertNoServerErrors', function () {
            return $this
                ->assertDontSee('Server Error')
                ->assertDontSee('Whoops!')
                ->assertDontSee('500');
        });
$browser->loginAs($user)
	->assertNoServerErrors()

Please or to participate in this conversation.