Col
(CC)
1
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.
1 Like
bpricilla
(Pricilla B)
2
@Col Welcome to the community
You can try this way:
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
2 Likes
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);
});
6 Likes