0
0
Postmantesting~10 mins

Response size in Postman - Test Execution Trace

Choose your learning style9 modes available
Test Overview

This test sends a GET request to an API endpoint and verifies that the response size is within the expected limit.

Test Code - Postman
Postman
pm.test("Response size is less than 500KB", function () {
    const responseSize = pm.response.size().body;
    pm.expect(responseSize).to.be.below(500 * 1024);
});
Execution Trace - 5 Steps
StepActionSystem StateAssertionResult
1Test startsPostman app is open with the test script loaded-PASS
2Sends GET request to the API endpointRequest sent, waiting for response-PASS
3Receives response from the serverResponse received with status 200 and body content-PASS
4Calculates response body size in bytes using pm.response.size().bodyResponse size calculatedResponse size is less than 512000 bytes (500KB)PASS
5Assertion checks if response size is below 500KBAssertion executedpm.expect(responseSize).to.be.below(500 * 1024)PASS
Failure Scenario
Failing Condition: Response body size is 500KB or more
Execution Trace Quiz - 3 Questions
Test your understanding
What does the test verify about the API response?
AThe response status code is 404
BThe response size is less than 500KB
CThe response contains a specific JSON key
DThe response time is under 1 second
Key Result
Always verify response size to ensure API responses are efficient and within expected limits, preventing performance issues.