Richard @pretzelhands.com · Dec 19

Hey, Laravel friends! I'm stumped by an error. In my test if I update a user and then check that the name is correctly displayed, the test works fine. (right image) But if I first check if the old name is displayed, then update the user and then check the name again, the test fails (left image)

2 likes 5 replies

?

Replies

Wilbert Liu · Dec 19

@nunomaduro.com should have an idea for this :)

Joel Clermont · Dec 20

Running multiple requests in a single test leaks a lot of application state between them. Laravel assumes one request per test and handles the teardown for you.

RVxLab · Dec 19

I feel your testing approach is wrong here. What you should consider is testing the GET and PUT endpoints separately as they’re different actions. Your test to show the correct name given a model shouldn’t care about what happens during an update and vice versa.

boptom · Dec 19

Which assert fails? My guess is the model is stale and you need a ->refresh() of it.

Richard · Dec 19

Does anyone have an idea what's going on here? Is either Pest or Laravel internally caching the clients.index view with the given data?