Test Overview
This test sends a request to an API endpoint and verifies that the response time is within an acceptable limit, ensuring the API is fast enough for users.
This test sends a request to an API endpoint and verifies that the response time is within an acceptable limit, ensuring the API is fast enough for users.
pm.test("Response time is less than 500ms", function () { pm.expect(pm.response.responseTime).to.be.below(500); });
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Send HTTP GET request to the API endpoint | Postman sends the request and waits for the response | — | PASS |
| 2 | Receive response from the API | Response received with status code 200 and response time recorded | — | PASS |
| 3 | Check if response time is less than 500 milliseconds | Response time is measured (e.g., 350ms) | Assert responseTime < 500ms | PASS |
pm.response.responseTime represent in Postman?pm.response.responseTime returnspm.response.responseTime gives the time in milliseconds the server took to respond.pm.test with a callback and pm.expect for assertions.pm.expect(pm.response.responseTime).to.be.below(500).pm.test('Check response time', () => {
pm.expect(pm.response.responseTime).to.be.below(300);
});pm.test('Response time test', () => {
pm.expect(pm.response.responseTime).to.be.lessThan(400);
});below, not lessThan.lessThan causes a syntax error because it is not recognized.lessThan is not valid in Postman assertions -> Option BPass the test and this pattern moves unknown