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");
The Postman Body tab gives you several tools to help you understand the response quickly. You can view the body in one of four views: Pretty, Raw, Preview, and Visualize. in the results pane. You can also place your cursor in the response and select ⌘+F or Ctrl+F.
In Postman, we can write the assertion in many ways. One of the simplest ways is the snippets, which are nothing but a block of codes that have some unique functions inside it and are available in the postman app. Users can easily access the snippets and can get the code inside the tests editor and run the test.
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']);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With