testingautomated-testspostmanpostman-collection-runner

How to Set Postman Test Equal to This or That


I am writing an API test in Postman, and I would like it to succeed if a Number is returned or the string "NA".

Based on my current understanding one condition can be tested at a time, like:

pm.test('Qty returned is number', () => {
  pm.expect(typeof parseInt(pm.response.json().qty)).to.be.not.equal('NaN');
});

Writing as two separate tests, one will pass and one will fail.

How can I code this exception into a single test?


Solution

  • Worked for my case, wanted the test to pass if one of two values is returned:

    .to.be.oneOf(["value1","value2"]);
    

    answer from jaikl