Postman 'or' Test Cases

Hello there. I’m currently setting up a suite of test cases in Postman (first time using it, but it generally seems nice and easy so far, but have come across a slight issue. Due to the numbers and timescales we work with, there are acceptable variances due to rounding. Is there anyone who might be able to advise on how I can write my tests to allow this, please? My current test is:

pm.expect(regularPayment).to.eql(540.68);

But the result is an acceptable 540.69.

Thank you in advance.

Postman is using javascript for the code parts.
So you can check if the value is between two other value, set a variable to true/false and verify that.

 var margin = 0.05;
 var average = 540.65;
 var upperlimit = average + margin;
 var underlimit = average - margin;
 var result = false;
     
if(regularPayment < upperlimit && regularPayment > underlimit){
    result = true;
}
pm.expect(result).to.be.true;
3 Likes

That did the trick. Thank you.