marcow's avatar
Level 13

Browser Exception but test passes

Hi everyone! In one of my blade views I introduced an error by referencing a misspelled relation, eg: {{ $item->type->name }} instead of {{ $item->item_type->name }}

When I hit the endpoint with the browser as expected I see an ErrorException: Attempt to read property "name" on null (View: .../index.php)

Now my problem is, that the test passes, even if it should not:

$response = $this->get('/inventory');
$response->assertSuccessful();
$response->assertSee('Some Text from the View');

Can someone help me on the right track for my tests?

0 likes
2 replies
mvd's avatar
mvd
Best Answer
Level 48

Hi @marcow

That is weird, should be a 500 status.

You will see '200' if you run dd($response->status()) in your test?

No if statement around $item ?

marcow's avatar
Level 13

@mvd oh my, that's embarassing. There is indeed an if statement in the view and after I staged my test correctly, I receive the 500 status as expected. Thanks for the hint!

1 like

Please or to participate in this conversation.