Test Overview
This test sends a request to an API endpoint and verifies that the response time is less than 500 milliseconds. It ensures the API responds quickly enough for good user experience.
Jump into concepts and practice - no test required
This test sends a request to an API endpoint and verifies that the response time is less than 500 milliseconds. It ensures the API responds quickly enough for good user experience.
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 | Test starts and sends HTTP request to the API endpoint | Postman sends request and waits for response | — | PASS |
| 2 | Postman receives response from API | Response received with status code and response time recorded | — | PASS |
| 3 | Test script checks if response time is below 500 milliseconds using pm.expect | Response time value available in pm.response.responseTime | pm.expect(pm.response.responseTime).to.be.below(500); | PASS |
pm.response.responseTime represent in Postman tests?pm.response.responseTimepm.response.responseTime. To check if it is less than 500ms, use to.be.below(500).pm.response.responseTime with to.be.below() [OK]pm.test('Response time is acceptable', () => {
pm.expect(pm.response.responseTime).to.be.below(400);
});pm.response.responseTime to be below 400 milliseconds.pm.test('Response time check', function() {
pm.expect(pm.response.responseTime).to.be.lessThan(300);
});to.be.below(), not lessThan().lessThan is incorrect in Postman tests -> Option Ato.be.below() not lessThan() [OK]to.be.at.most(1000) checks if value is less than or equal to 1000, matching the requirement. to.be.below(1000) excludes 1000, to.equal(1000) only passes exactly 1000, and to.be.above(1000) is opposite.