I have a signup API that returns a JSON response in this kind of format
{
"meta": {
//response metadata
},
"data": {
//user object
}
}
I want to test this response with AssertableJson but I'm only concerned about the user object.
How do I use AssertableJson only for the data property of the response?
I've tried something like this with no success
$response->data->assertJson(
function(AssertableJson $json){
$json->whereType('id', 'string')
->where('email', '[email protected]')
->etc();
}
);
You should use
hasto tell Laravel to look at thedatakey, and don't forget to useetc()docetc()allows an object to have additional keys not specified in the assert