Could you post the whole test? Cos it seems like you're doing something in-between so that you don't see the $goal->name in the result any more. Can't help much without knowing the rest of the logic
May 21, 2018
5
Level 10
Laravel - when hitting web route twice in one test (get request)
Earlier in the test I have
$response = $this->get(route('home'));
$response->assertSee($goal->name);
Then some action, other lines of code
And then
$response = $this->get(route('home'));
$response->assertDontSee($goal->name);
And the assertion fails. But it shouldn't. It works great! And when I remove earlier two lines of code, I mean:
$response = $this->get(route('home'));
$response->assertSee($goal->name);
Now tests green and everything is fine.
I don't know what this is about, but I guess it's because it hits route('home') twice in the same test. As view is cached? As it gets the same output as before despite the new get request?
I don't know. Tried many things, e.g. $this->refreshApplication(); with no green result. Tried also Artisan::call('view:clear');, still the same.
What to do? What is this about?
Please or to participate in this conversation.