lundi 21 mai 2018

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 deleted 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.

What to do? What is this about?

Aucun commentaire:

Enregistrer un commentaire