Hi have an scenario, Were my API Requests also only 2500$ in a Request , If i send my Request more than 2500$ , How to verify the value in Tests and displays my error message ?
how to use the condition ? to verify and shows the error.
Please advise
My parameter
Amount : 2500
I have created a Variable as “amnt”
pm.expect(jsonData.data.bill).to.eql(amnt);
What if i pass 2600 in my request and how to verify in Tests and capture the error.
pm.test("Billing amount is less than 2500", function(){
pm.expect(jsonData.data.bill<2500)
//or based on the req
//pm.expect(jsonData.data.bill<=2500)
});
let count = [1,2,3,4]
pm.expect(count.length>4); - step is passing
pm.expect(count.length).to.be.above(4); - receving assertion error failure
kindly help me what is the difference or mistake ?
Think of its as expected result vs actual result, with the expected and actual results being contained within the parenthesis (). With the words between the two parenthesis being the actual comparison.
Your line is basically just saying pm.expect(expectedresult). You don’t have an assertion included. You can include functions within the parenthesis, which is why its not just erroring when it compiles. It will always pass as its not actually comparing itself with anything. It’s just a statement at this point.
This is incorrect by the way and doesn’t fail the assertion like it should.
let bill = 2600
pm.test("Billing amount is less than 2500", function(){
pm.expect(bill < 2500)
});
This works and fails the assertion.
pm.test("Billing amount is less than 2500 v2", function(){
pm.expect(bill).to.be.below(2500)
});
Core advice with any automated test, is to ensure you can make the test fail to rule out any false positives.