Level 60
Use a simple assertion like assertSee() and something that you know it will be on your page, example
$browser->loginAs($user)
->visit(route('sample'))
->assertSee('Laravel');
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?
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.