I've defined several collection tests that fire after each individual test in collection. See below
pm.test("Status code is not of error type", function() {
pm.expect(pm.response.code).to.not.eql(500);
});
pm.test("Content-Type is present", function () {
pm.response.to.have.header("Content-Type");
});
pm.test("Response must be valid json", function () {
pm.response.to.be.withBody;
pm.response.to.be.json;
});
I'd like to extend them further. Ideally, I'd like to run different tests based on the method type they were sent with. For instance, I'd like to test each DELETE request for the following.
pm.expect(pm.response.code).to.be.oneOf([204, 409])
Is it possible to define this at a collection level? Or do I need to paste this line into each delete request I have?