i have response body as follows:
{
"data": {
"id": 2,
"email": "[email protected]",
"first_name": "Janet",
"last_name": "Weaver",
"avatar": "https://reqres.in/img/faces/2-image.jpg"
},
"support": {
"url": "https://reqres.in/#support-heading",
"text": "To keep ReqRes free, contributions towards server costs are appreciated!"
}
}
so to validate types in the response body i have written code as
const jsonData= pm.response.json();
pm.test("testing type in the response body", () =>{
pm.expect(jsonData).to.be.an("object");
pm.expect(jsonData.data).to.be.an("object");
pm.expect(jsonData.id).to.be.a("number");
pm.expect(jsonData.email).to.be.a("string");
pm.expect(jsonData.first_name).to.be.a("string");
pm.expect(jsonData.last_name).to.be.a("string")
});
but i’m getting error as :
testing type in the response body | AssertionError: expected undefined to be a number
testing type in the response body | AssertionError: expected undefined to be a string
Can anyone help me why am i getting the following errors?