OR operator in Postman Response Tests

Viewed 10867

I have the following assertion in my postman script test, but for some reason the tests are failing when one of the following is missing: Lease, Finance, or cash in my response body. Is the "||" not the OR operator?

tests["Deal Type"] = responseBody.has("Lease" || "Finance" || "Cash");
3 Answers

It should be something like:

pm.expect(pm.response.code).to.be.oneOf([201,202]);

According to the postman docs the correct syntax would be

tests["Deal Type"] = responseBody.has("Lease") || responseBody.has("Finance") || responseBody.has("Cash");

Write it is like this..

pm.expect(pm.response.data[0].DealType).to.be.oneOf(['Lease', 'Finance','Cash']);
Related