Hitting API w/ GET request, checking if item has been deleted by globals.id variable, have test inside forloop and when I run test returns 0/0 tests passed. All of my console logs within the for loop work, the objects contain values matching what I have as well. Anyone know how to do this?
var data = JSON.parse(responseBody);
for (var i = 0; i < data.length; i++){
tests["id has been deleted"] = data[i].id !== globals.id;
if(data[i].id !== globalID){
tests["id has been deleted"] = data[i].id !== globals.id;
return true;
}
}
I could make test with for loop. My Json:
{
"rows": [
{
"id": "2804",
"title": "Some title",
...
},
...
],
"total": "2788"
}
My test:
for (var i in data.rows){
var obj = data.rows[i];
tests["title of row #" + i + " is not null"] = !!obj.title;
tests["title of row #" + i + " is not empty"] = obj.title !== "";
}
But if I use "return true" Postman shows "Tests (0/0)"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With