Last active
March 27, 2019 12:10
-
-
Save abhilashshettigartrt/27666a2323f1ba934aea2e8cf160b6f6 to your computer and use it in GitHub Desktop.
Postman Test cases
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// example using pm.response.to.have | |
pm.test("response is ok", function () { | |
pm.response.to.have.status(200); | |
}); | |
// example using response assertions | |
pm.test("response should be okay to process", function () { | |
pm.response.to.not.be.error; | |
pm.response.to.have.jsonBody(""); | |
pm.response.to.not.have.jsonBody("error"); | |
}); | |
// example using pm.response.to.be* | |
pm.test("response must be valid and have a body", function () { | |
// assert that the status code is 200 | |
pm.response.to.be.ok; // info, success, redirection, clientError, serverError, are other variants | |
// assert that the response has a valid JSON body | |
pm.response.to.be.withBody; | |
pm.response.to.be.json; // this assertion also checks if a body exists, so the above check is not needed | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment