Below is the json response, I want to make sure “status” property is present. I don’t want to test for the value of the status i.e. 422
I tried with the following, but no luck.
pm.expect(responseInJson).to.have.property(‘errors[0].extensions.data.status’);
Blockquote
{
"errors": [
{
"message": "UnprocessableEntityError",
"path": [
"login"
],
"extensions": {
"code": "UNPROCESSABLE_ENTITY_ERROR",
"name": "Unprocessable Entity",
"data": {
"errorCode": "",
"status": 422,
"friendlyMessage": "Could not register at this time. Please try again later"
}
}
}
],
"data": null
}
Update:
I was able to assert using the below code, but would like to know what is the difference between the 2?
//This one works
pm.response.to.have.jsonBody(“data.loginPowerPassCard.accessToken”);
//This one doesnt
pm.expect(responseInJson).to.have.property(“data.loginPowerPassCard.accessToken”);