Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save alexandramartinez/a3585c3bf1f5cc69a64cdcb01297eaa9 to your computer and use it in GitHub Desktop.
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)
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