# How to write correct test - If I want to expect response to include PART oneOf text

**URL:** <https://community.postman.com/t/how-to-write-correct-test-if-i-want-to-expect-response-to-include-part-oneof-text/20548>\
**Category:** Help Hub\
**Tags:** tests, response, expect\
**Created:** [February 18, 2021, 5:16pm UTC](https://community.postman.com/t/how-to-write-correct-test-if-i-want-to-expect-response-to-include-part-oneof-text/20548 "2021-02-18T17:16:28Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![dbtest27](https://avatars.discourse-cdn.com/v4/letter/d/f08c70/32.png) [@dbtest27](https://community.postman.com/u/dbtest27)\
**Post date:** [February 18, 2021, 5:16pm UTC](https://community.postman.com/t/how-to-write-correct-test-if-i-want-to-expect-response-to-include-part-oneof-text/20548/1 "2021-02-18T17:16:28Z")

</div>

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 -

1. 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

2. 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

1. 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
2. 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
3. and a lot of other not working combinations.

Please help me to resolve my problem.

---

<div class="post-metadata">

**Author:** ![dbtest27](https://avatars.discourse-cdn.com/v4/letter/d/f08c70/32.png) [@dbtest27](https://community.postman.com/u/dbtest27)\
**Post date:** [February 18, 2021, 9:04pm UTC](https://community.postman.com/t/how-to-write-correct-test-if-i-want-to-expect-response-to-include-part-oneof-text/20548/2 "2021-02-18T21:04:46Z")

</div>

Thanks! I got it

let responseJson = xml2Json(responseBody);

if (pm.test(“Error\_num matches”, function () {  
pm.expect(responseJson.postresponse).to.have.property(‘errornum’).and.to.be.oneOf([‘994’, ‘1’]);  
}));  
and its working!
