I have a control that returns 2 records:
{
"value": [
{
"ID": 5,
"Pupil": 1900031265,
"Offer": false,
},
{
"ID": 8,
"Pupil": 1900035302,
"Offer": false,
"OfferDetail": ""
}
]
}
I need to check through Postman that I have 2 entries. I tried various methods that I found here and elsewhere, but no luck. Using the code below does not return the expected response.
responseJson = JSON.parse(responseBody);
var list = responseBody.length;
tests["Expected number"] = list === undefined || list.length === 2;
At this point, I'm not sure if this is an API that I am testing for fault or my coding. I tried iterating over the returned elements, but this also does not work for me. Could someone advise, please, I am new to javascript, so I expect this to be the obvious reason for my problem, but I don't see it. Many thanks.
source
share