I'm trying to make a test in POSTMAN where the size has to be greater than 0 but I haven't been able to make the test correctly.
What I did was to make it fail when the size is smaller than 0.
Is there a function in postman to check if the size is greater than x number?
pm.test("Step 7/ Getting the resources and availabilites list " , function(){
pm.expect(pm.response.code).to.be.oneOf([200]);
if(pm.response.code === 200){
var jsonData = JSON.parse(responseBody);
var sizeOK= 1;
if(jsonData.resources.length>0){
}else{
//I will make the test fail if there is not data available on the response.
pm.test("Response body is empty ", function () {
pm.expect(pm.response.json().resources.length).to.equal(1);
});
}
console.log(Boolean(jsonData.resources.length>1))
}
});
pm.expect(pm.response.json().resources.length).to.be.above(0);