I am currently creating a test in Postman to verify if a JSON response contains the 'RegressieMapTest' Label. Here is my script:
pm.test("Is the folder created correctly?", function(){
var jsonData = pm.response.json();
var objString = JSON.stringify(jsonData);
var obj = JSON.parse(objString);
for (var i = 0; i < obj.Corsa.Data.length; i++){
if (obj.Corsa.Data[i].Label == "RegressieMapTest"){
console.log(obj.Corsa.Data[i].Label);
pm.expect(obj.Corsa.Data.Label).to.eql("RegressieMapTest");
}
}
pm.expect.fail();
})
However, I am running into an issue as every time I execute this script, it seems to automatically go to pm.expect.fail(), even though 'RegressieMapTest' is present in the JSON response. The error message returned by Postman is:
Is the folder created correctly? | AssertionError: expect.fail()