php - How to test a nested JSON data present in JSON file in Laravel?
one text
Solution:
Try this (using Laravel 8.x):
$response
->assertOk()
->assertJson(
fn (AssertableJson $json) =>
$json->has('category')
->has(
'items',
1,
fn ($json) =>
$json->where('item1', "mojito")
->where('item2', 'cocacola')
)
);
Here is the official documentation.
Source