I have a field in a return object called “PRODUCT”. The JSON response returns all items for every product, but I need to execute some tests for some products, and some for others.
response.ProductLongName is the field.
What I would I would like to do is something like:
if (reponse.ProductLongName.contains("product1")) {
// Set of tests for product 1
} elseif(reponse.ProductLongName.contains("product1")) {
// Set pf tests for product 2
}
You’re already doing this with the conditional statement you have above. What you need to do now is to author these tests within that specific conditional code blocks.
The test scripts are written in JavaScript, so any valid JavaScript code will run there.
I see you already know how to author tests with Postman Scripts but let me know if you need any further help with that.