I have a json array coming from my api as response:
{
"data": [
{
"id": 1,
"name": "abc"
}
}
I am using laravel
for api and laravel-codeception
for testing.
public function getAll(ApiTester $I)
{
$I->sendGET($this->endpoint);
}
I have to test if the response contains only id
and name
key (not any other key) example this response should fail the test.
{
"data": [
{
"id": 1,
"name": "abc",
"email":"abc@xyz"
}
}
I have found $I->seeResponseContainsJson()
, but it checks if JSON is present or not. It does not check if JSON response contains only specified keys.
Thanks.
Aucun commentaire:
Enregistrer un commentaire