Created
June 8, 2020 21:20
-
-
Save alexandramartinez/a3585c3bf1f5cc69a64cdcb01297eaa9 to your computer and use it in GitHub Desktop.
Example created for Intro to Regression Testing with Postman (https://www.prostdev.com/post/intro-to-regression-testing-with-postman)
This file contains 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
var jsonData = pm.response.json(); | |
pm.test("Content-Type is present", function () { | |
pm.response.to.have.header("Content-Type"); | |
}); | |
pm.test("Content-Type is application/json", function () { | |
pm.expect(postman.getResponseHeader("Content-Type")).to.include("application/json"); | |
}); | |
pm.test("Body is present", function () { | |
pm.response.to.have.body(); | |
}); | |
pm.test("Body is a valid json", function () { | |
pm.response.to.be.json; | |
}); | |
pm.test("ok: true", function () { // #5 | |
pm.expect(jsonData.ok).to.eql(true); | |
}); | |
pm.test("team.name: ProstDev", function () { // #6 | |
pm.expect(jsonData.team.name).to.eql("ProstDev"); | |
}); | |
pm.test("Status code is 200", function () { // #7 | |
pm.response.to.have.status(200); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment