# Include variable in pm.test

**URL:** <https://community.postman.com/t/include-variable-in-pm-test/21937>\
**Category:** Help Hub\
**Tags:** tests, variables, json\
**Created:** [March 26, 2021, 2:18pm UTC](https://community.postman.com/t/include-variable-in-pm-test/21937 "2021-03-26T14:18:53Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Col](https://avatars.discourse-cdn.com/v4/letter/c/898d66/32.png) [@Col](https://community.postman.com/u/Col)\
**Post date:** [March 26, 2021, 2:18pm UTC](https://community.postman.com/t/include-variable-in-pm-test/21937/1 "2021-03-26T14:18:53Z")

</div>

Hi all,

I am trying to display a variable {{OUTPUT}} to my test query.

```
pm.test("Status code is 202 {{OUTPUT}}", () => {

  pm.response.to.have.status(202);

});

```

The exported json output file would then display the status message followed by the output variable, as below.

```
"allTests": [
				{
					"Status code is 202 {{OUTPUT}}": true
				},

```

The variable is only contained within the request body / header and also within the file used for the runner.

Any help is much appreciated.

---

<div class="post-metadata">

**Author:** ![bpricilla](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/bpricilla/32/6511_2.png) [@bpricilla](https://community.postman.com/u/bpricilla)\
**Post date:** [March 26, 2021, 2:47pm UTC](https://community.postman.com/t/include-variable-in-pm-test/21937/2 "2021-03-26T14:47:54Z")

</div>

@Col Welcome to the community 🥳

You can try this way:

```auto
pm.test("Status code is 202 " + pm.environment.get("OUTPUT"), function () {

    pm.response.to.have.status(202);
});

```

Change the scope of the variable you have used, if its not environmental variable. Please let me know if you have any issues 🙂

---

<div class="post-metadata">

**Author:** ![praveendvd](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/praveendvd/32/6796_2.png) [@praveendvd](https://community.postman.com/u/praveendvd)\
**Post date:** [March 26, 2021, 5:55pm UTC](https://community.postman.com/t/include-variable-in-pm-test/21937/3 "2021-03-26T17:55:52Z")

</div>

you can try as @bpricilla mentione or can use replacein

```
  pm.test(pm.variables.replaceIn("Status code is 202 {{OUTPUT}}"), () => {

      pm.response.to.have.status(202);

    });
```
