Problem in this Loop //Test to Check W2B001 is received same from API as well//Test that the response is an Int or date
I have an Array like this
"dates": [{
"id": 1,
"date": "2019-06-30T00:00:00"
},
{
"id": 2,
"date": "2019-04-30T00:00:00"
},
{
"id": 3,
"date": "2019-08-31T00:00:00"
},
{
"id": 4,
"date": "2019-10-31T00:00:00"
},
{
"id": 5,
"date": "2019-02-28T00:00:00"
},
{
"id": 6,
"date": "2018-12-31T00:00:00"
}
]
};
pm.test("Verify that the Address Type and Datatype are matching the Soap UI response ", function () {
for (var i = 0; i < jsonData.dates.length; i++)
{
var datedata = jsonData.dates[i].date;
if (datedata === "2019-06-30T00:00:00") {
pm.variables.set("test_status", "passed");
console.log(datedata);
}else
{
pm.variables.set("test_status", "failed");
}
}
console.log(pm.variables.get("test_status"));
console.log(datedata);
console.log(jsonData.creditCommitments.length);
});
I want to validate that the date is matching, but the problem I am facing is that the postman received array element is not always received as sorted. So It passes once and not passing the second time. Any Idea how to fix it ?