When testing in Postman, you can use pm.response.to.have.status(200)
to assert that the response status should be 200.
Is there any simple way to assert multiple statuses? I tried pm.response.to.have.status(200||404)
and it didn't work.
I'm looking at the Postman Sandbox API Reference and there doesn't seem to be a straightforward solution for this, although maybe something can be worked out.
Since it's rather bizarre, I'll explain why I want this: it's a DELETE request that will standardize the database for later requests and I don't care which is returned as long as it's either 200 or 404.
(It's OK to Ask and Answer Your Own Questions)
Found an example in the test examples:
pm.test("Successful POST request", function () {
pm.expect(pm.response.code).to.be.oneOf([201,202]);
});
in my case, it would be something like
pm.test("Previous DELETE request", function () {
pm.expect(pm.response.code).to.be.oneOf([200,404]);
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With