# Pm.test to.include a varible

**URL:** <https://community.postman.com/t/pm-test-to-include-a-varible/8940>\
**Category:** Help Hub\
**Created:** [November 12, 2019, 8:33am UTC](https://community.postman.com/t/pm-test-to-include-a-varible/8940 "2019-11-12T08:33:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![theToncheff](https://avatars.discourse-cdn.com/v4/letter/t/82dd89/32.png) [@theToncheff](https://community.postman.com/u/theToncheff)\
**Post date:** [November 12, 2019, 8:33am UTC](https://community.postman.com/t/pm-test-to-include-a-varible/8940/1 "2019-11-12T08:33:24Z")

</div>

Hey, how can I check the body response if it includes a variable?  
I want to check if the body includes a certain string, however I want to give the variable to be checked, but haven’t been able to get the postman to work it it.  
-the variable is a string, used earlier in the collection and it acts like a title, that should appear on my get request. the below script works if I put the string itself, however I want to put the variable, as I change the variable often and don’t to manually change the string.

`pm.test("Body matches string", function () { pm.expect(pm.response.text()).to.include(Variable); });`

---

<div class="post-metadata">

**Author:** ![danny-dainton](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/danny-dainton/32/29401_2.png) [@danny-dainton](https://community.postman.com/u/danny-dainton)\
**Post date:** [November 12, 2019, 8:49am UTC](https://community.postman.com/t/pm-test-to-include-a-varible/8940/2 "2019-11-12T08:49:55Z")

</div>

Hey @theToncheff

Where are you declaring the variable?

If it is set as an environment, global or collection variable - you can use `pm.variables.get('var_name')` in the `.include()` function or use the specific variable scope to do the same thing.

---

<div class="post-metadata">

**Author:** ![theToncheff](https://avatars.discourse-cdn.com/v4/letter/t/82dd89/32.png) [@theToncheff](https://community.postman.com/u/theToncheff)\
**Post date:** [November 12, 2019, 8:58am UTC](https://community.postman.com/t/pm-test-to-include-a-varible/8940/3 "2019-11-12T08:58:56Z")

</div>

Yes, thank you! This is what I was trying to achieve.
