Last active
October 2, 2018 13:04
-
-
Save GantMan/8c6e4a332fca455706798c69f47ada55 to your computer and use it in GitHub Desktop.
Example API Tests for Star Wars API via Postman
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 testing: | |
// More found here: https://www.getpostman.com/docs/postman/scripts/test_examples | |
// TEST 1 | |
pm.test("response is ok", () => { | |
pm.response.to.be.ok // enforce 200ish | |
// same as above pm.response.to.not.be.error | |
// HTTP good, but contents cannot say error | |
pm.response.to.not.have.jsonBody("error") | |
}) | |
// TEST 2 | |
pm.test("Body has string `wheeled`", () => { | |
pm.expect(pm.response.text()).to.include("wheeled") | |
}) | |
// TEST 3 | |
pm.test("Check Name", () => { | |
const jsonData = pm.response.json() | |
pm.expect(jsonData.name).to.eql('Sand Crawler') | |
}) | |
// TEST 4 | |
pm.test("Response time is less than 500ms", () => { | |
pm.expect(pm.response.responseTime).to.be.below(500) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment