Include variable in pm.test

Hi all,

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

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


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.

1 Like

@Col Welcome to the community :partying_face:

You can try this way:

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

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


you can try as @bpricilla mentione or can use replacein

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