Over the past week i’ve been playing about with the test tab and the Visualise tab, within it i discovered you can display image/gif which can correspond to whether all tests successfully pass, and another image/gif if one or more tests fail (Just for a bit of Fun)
However today when i run a call with the same un altered code I’ve been using previously, the images aren’t displaying anymore.
Hi thanks for the response, yeah the 15 days of Postman is where i discovered this and used this example to explore and have fun with the GIFs resulting in the tests, but i did also use the Test Counter that it’s using too, the code i’m using is below.
// Test Counter
let pass = 0
let totalToPass = 3
let collection = pm.response.json().collection
console.log("The request that's running is", pm.info.requestName)
pm.test("Status code is 200", function () {
pm.response.to.have.status(200);
pass += 1
});
pm.test("Response time is less than 5000ms", function () {
pm.expect(pm.response.responseTime).to.be.below(5000);
pass += 1
});
pm.test("Response must be valid and have a body json", function (){
pm.response.to.be.ok;
pm.response.to.be.json
pass += 1
});
// GIFs for Test Results
let template
if (pass == totalToPass) {
template = `🟢 All Tests have Passed!
<br />
<img src="https://media.tenor.com/rz4Ii3zzuJkAAAAM/the-it-crowd-it-crowd.gif"/>
`
} else {
template = `🔴 Fails in the Test Run!
<br />
<img src="https://media.tenor.com/qp5VLQ9Cg24AAAAC/it-crowd-on-fire.gif"/>
`
}
pm.visualizer.set(template)
I do get the results of test has passed/failed however the GIFs don’t display. I may have copied an additional character in there somewhere but I can’t spot it so another set of eyes are welcome.
I actually found out what the issue was, I was copying the code in from a Confluence page and it seems it just doesn’t like it in Postman, it either changes some characters or the Tests field doesn’t like the formatting when it’s pasted in.