Belle
Belle

Reputation: 11

OR operator for postman

I treat the test result as pass either field A is "A" or field B is "B". How can i achieve that in postman?

I tried

(pm.expect(responseJson.output.generic[0].fieldA).to.eql(pm.iterationData.get("A"))||pm.expect(responseJson.output.generic[0].fieldB).to.eql(pm.iterationData.get("B")))

Upvotes: 0

Views: 530

Answers (1)

Ral
Ral

Reputation: 51

You can try

pm.expect(cond1 || cond2).to.be.true;

In your case, I think that would be something like

pm.expect(
    responseJson.output.generic[0].fieldA === pm.iterationData.get("A") || 
    responseJson.output.generic[0].fieldB === pm.iterationData.get("B")
  ).to.be.true;

Upvotes: 1

Related Questions