Last active
March 22, 2025 20:30
-
-
Save jalallinux/6b8bf5e37c8bff0a1dcc82d1df3133ac to your computer and use it in GitHub Desktop.
Postman: Performance Test
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
pm.test("Successful request", function () { | |
pm.expect(pm.response.code).to.be.oneOf([200, 201, 202]); | |
}); | |
pm.test("Response time is less than 217ms.", function () { | |
pm.expect(pm.response.responseTime).to.be.below(217); | |
}); | |
pm.test("Response time is less than 317ms", function () { | |
pm.expect(pm.response.responseTime).to.be.below(317); | |
}); | |
pm.test("Response time is less than 871ms", function () { | |
pm.expect(pm.response.responseTime).to.be.below(871); | |
}); | |
pm.test("Content-Type is present", function () { | |
pm.response.to.have.header("Content-Type"); | |
}); | |
pm.test("Status code is 200", function () { | |
pm.response.to.have.status(200); | |
}); | |
pm.test("Body has code", function () { | |
pm.expect(pm.response.json()).to.have.property("data"); | |
}); | |
pm.test("Body has message on failure", function () { | |
if (!pm.response.code.toString().startsWith('2')) { | |
pm.expect(pm.response.json()).to.have.property('message'); | |
pm.expect(pm.response.json().message).to.be.a('string'); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Source: Postman answers - Scripts