Hi,
Couldn’t find any similar post either which I could use.
I want to add a tests to check whether a PART (1 out of 2 ) of value is present in response
For example if response CONTAIN text “0” OR “1” - > I want test to be PASS.
For me working -
-
pm.test(“Status code is 200”, function () {
pm.expect(pm.response.code).to.be.oneOf([200, 201]);
}); - in this case Postman checking if response EQUALS 1 out of 2 my expecting value. It pass if I get 200 or 201 status code -
pm.test(“Error_num matches”, function () {
pm.expect(pm.response.text()).to.include(“0”); - in this case Postman checking if response CONTAIN “0”, if yes → Pass
But I need combine this conditions.
I need Test to be PASS if response CONTAIN first OR second textExpectingResult
I tried already this, and its not working
- pm.expect(pm.response.text()).to.include(pm.variables.get(“Error_num”));
pm.expect(pm.response.text()).to.be.oneOf([(“1”), (“1”)]); //with or without (), using to.include or to.includes - pm.test(“Error_num matches”, function () {
pm.expect((pm.response.text()).to.include(“0”) || (pm.response.text()).to.include(“1”)).to.be.true; //or without .to.be.true - and a lot of other not working combinations.
Please help me to resolve my problem.