In the postman I have following test. How to give assertion success or error message. I don't want to give message as console.log("my msg"). Coz console message goes to the console.I want to show the message as in the picture where postman shows pass or fail.
pm.test("Full version number present in response headers optional", () => {
let apiVersion = pm.response.headers.get("API-Version")
pm.expect(apiVersion).match(/[-.0-9]+/)
})
Official documentation in here.
Only can add extra message when it is failed.
Example for demo - 3rd item
var jsonData = JSON.parse(responseBody);
const apiVersion = undefined
pm.test('Full version number present in response', function () {
pm.expect(apiVersion).match(/[-.0-9]+/)
});
const apiVersion1 = '1.2.3'
pm.test('Full version number present in response', function () {
pm.expect(apiVersion1).match(/[-.0-9]+/)
});
pm.test('Full version number present in response', function () {
pm.expect(null,"extrame message").match(/[-.0-9]+/)
});