The TestResponse::assertJsonStructureMissing
assertion works just like TestResponse::assertJsonStructure, except that it tests for the absence of a particular structure.
$response = $this->get('/data');
$response->assertJsonStructureMissing([
'data' => [
'related' => [
'*' => [
'attribute',
],
],
],
]);
Full credit for this package goes to Behzad Shabani. This package just takes his pull request and packages it up so it's super easy to add to your Laravel application.