Skip to content

Instantly share code, notes, and snippets.

@jalallinux
Last active March 22, 2025 20:30
Show Gist options
  • Save jalallinux/6b8bf5e37c8bff0a1dcc82d1df3133ac to your computer and use it in GitHub Desktop.
Save jalallinux/6b8bf5e37c8bff0a1dcc82d1df3133ac to your computer and use it in GitHub Desktop.
Postman: Performance Test
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');
}
});
@jalallinux
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment