Laravel testing, get JSON content

Proper way to get the content is:

$content = $this->get('/v1/users/1')->decodeResponseJson();

Currently in 5.3 this is working...

$content = $this->get('/v1/users/1')->response->getContent();

It does break the chain, however since response returns the response and not the test runner. So, you should make your chainable assertions before fetching the response, like so...

$content = $this->get('/v1/users/1')->seeStatusCode(200)->response->getContent();


I like to use the json method when working with json, instead of ->get()

$data = $this->json('GET', $url)->seeStatusCode(200)->decodeResponseJson();