Thanks for reply @michaelderekjones .
No I don’t want to print on console. in collection it should say test ran or not. I want to create test for each jsonhelper, I was trying following code but getting error
postman.setGlobalVariable(“verifyJsonBodyOrNot”, function verifyJsonBodyOrNot() {
let jsonHelpers = {};
jsonHelpers.verifyJsonBody = pm.test("Verifying response have Json body"), function verifyJsonBody(){
pm.response.to.be.withBody;
pm.response.to.be.json;
}
jsonHelpers.verifyNoJsonBody = pm.test("Verifying response doesn't have Json body"),function verifyJNosonBody(){
pm.response.to.not.be.withBody;
pm.response.to.not.be.json;
}
return jsonHelpers;
Sorry, I don’t quite get what you are trying to achieve.
All you are doing at the moment, is setting a global variable (which is probably not the scope you need) with the text of the code that follows (as a string).
It’s not actually doing anything else as far as I can tell.
What is it you actually want to test? That the response is JSON or not?