Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use OR operator in postman pm.test

Tags:

postman

I am attempting to create a test that checks a json response to contain either one property or another.

My example:

pm.expect(jsonData.data.owner).to.have.property('orgName') || 
pm.expect(jsonData.data.owner).to.have.property('firstName')

I can't seem to find any documentation on using or operators in the new pm.expect() syntax.

like image 453
Ryan Avatar asked Oct 19 '25 16:10

Ryan


1 Answers

use oneOf() method

pm.expect(jsonData.carrierType.type).to.be.oneOf(["mobile", "landline"]);
like image 141
Sandra Pavan Avatar answered Oct 22 '25 05:10

Sandra Pavan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!