Bird
Raised Fist0
Postmantesting~5 mins

Response size in Postman - Cheat Sheet & Quick Revision

Choose your learning style10 modes available
Recall & Review
beginner
What does response size mean in API testing?
Response size is the amount of data sent back by the server after an API request. It is usually measured in bytes or kilobytes.
Click to reveal answer
beginner
Why is monitoring response size important in testing?
Because large response sizes can slow down applications and use more bandwidth, affecting user experience and performance.
Click to reveal answer
beginner
How can you check response size in Postman?
After sending a request, Postman shows the response size in the response section, usually near the status code and response time.
Click to reveal answer
intermediate
What is a good practice when response size is too large?
Optimize the API to send only necessary data, use pagination, or compress the response to reduce size.
Click to reveal answer
intermediate
How can you write a test in Postman to check if response size is under 500 KB?
Use the test script:
pm.test('Response size is under 500KB', () => { pm.expect(pm.response.size()).to.be.below(500 * 1024); });
Click to reveal answer
What unit is commonly used to measure response size?
ASeconds
BPixels
CBytes
DDegrees
Where can you find response size information in Postman after a request?
AIn the environment variables
BIn the request URL bar
CIn the console logs only
DIn the response section near status code
Why should you keep response size small?
ATo improve loading speed and reduce bandwidth
BTo increase server CPU usage
CTo make the response look bigger
DTo confuse users
Which Postman method returns the response size in bytes?
Apm.environment.get()
Bpm.response.size()
Cpm.request.url()
Dpm.response.time()
What is a good way to reduce response size?
AUse pagination or compress data
BAdd more data fields
CSend multiple copies of the response
DIncrease server timeout
Explain how to check and test response size in Postman.
Think about where Postman shows response info and how to write tests.
You got /3 concepts.
    Why is controlling response size important in API testing?
    Consider what happens if response size is too big.
    You got /3 concepts.

      Practice

      (1/5)
      1. What does pm.response.size().body return in Postman?
      easy
      A. The total number of headers in the response
      B. The HTTP status code of the response
      C. The size of the response body in bytes
      D. The time taken to receive the response

      Solution

      1. Step 1: Understand the method pm.response.size()

        This method returns an object containing sizes of different parts of the response.
      2. Step 2: Identify what .body accesses

        The .body property specifically returns the size of the response body in bytes.
      3. Final Answer:

        The size of the response body in bytes -> Option C
      4. Quick Check:

        pm.response.size().body = response body size [OK]
      Hint: Remember .body gives size in bytes of response content [OK]
      Common Mistakes:
      • Confusing response size with status code
      • Thinking it returns header count
      • Assuming it returns response time
      2. Which of the following is the correct syntax to assert that the response body size is less than 5000 bytes in Postman test script?
      easy
      A. pm.response.size().body < 5000;
      B. pm.expect(pm.response.size().body).to.be.below(5000);
      C. assert(pm.response.body.size < 5000);
      D. pm.response.size.body < 5000;

      Solution

      1. Step 1: Identify correct assertion syntax in Postman

        Postman uses Chai assertion library with pm.expect() for assertions.
      2. Step 2: Check the correct property and method usage

        The correct way to get response body size is pm.response.size().body, and to assert it is below 5000 bytes, use to.be.below(5000).
      3. Final Answer:

        pm.expect(pm.response.size().body).to.be.below(5000); -> Option B
      4. Quick Check:

        Use pm.expect() with to.be.below() [OK]
      Hint: Use pm.expect() with to.be.below() for size assertions [OK]
      Common Mistakes:
      • Using incorrect property like pm.response.body.size
      • Missing pm.expect() wrapper
      • Using plain comparison without assertion
      3. Given the following Postman test script:
      <pre>pm.test('Body size check', () => { const size = pm.response.size().body; pm.expect(size).to.be.above(1000); pm.expect(size).to.be.below(3000); });
      What will happen if the response body size is 3500 bytes?
      medium
      A. The test will fail because 3500 is not below 3000
      B. The test will pass because 3500 is above 1000
      C. The test will fail because 3500 is not above 1000
      D. The test will pass because both conditions are true

      Solution

      1. Step 1: Analyze the assertions in the test

        There are two assertions: size must be above 1000 and below 3000 bytes.
      2. Step 2: Check the given size against assertions

        3500 is above 1000 (true) but not below 3000 (false), so the second assertion fails.
      3. Final Answer:

        The test will fail because 3500 is not below 3000 -> Option A
      4. Quick Check:

        3500 < 3000? No, test fails [OK]
      Hint: Check all assertions; one fail means test fails [OK]
      Common Mistakes:
      • Ignoring the upper bound assertion
      • Assuming test passes if one assertion passes
      • Confusing above and below conditions
      4. You wrote this Postman test:
      pm.test('Check response size', () => {
        pm.expect(pm.response.size.body).to.be.below(2000);
      });

      But the test always fails with an error. What is the problem?
      medium
      A. Incorrect property access; should use pm.response.size().body
      B. The assertion method to.be.below() is invalid
      C. pm.expect() cannot be used inside pm.test()
      D. Response size cannot be checked in Postman tests

      Solution

      1. Step 1: Identify the property access error

        The code uses pm.response.size.body which is incorrect because size is a function, not an object.
      2. Step 2: Correct the syntax

        The correct syntax is pm.response.size().body to get the response body size.
      3. Final Answer:

        Incorrect property access; should use pm.response.size().body -> Option A
      4. Quick Check:

        Use parentheses for size() function [OK]
      Hint: Remember size() is a function, not a property [OK]
      Common Mistakes:
      • Missing parentheses after size()
      • Misusing assertion methods
      • Thinking pm.expect() is invalid inside pm.test()
      5. You want to write a Postman test that fails if the response body size is either too small (less than 100 bytes) or too large (more than 5000 bytes). Which test script correctly implements this?
      hard
      A. pm.test('Body size limits', () => { const size = pm.response.size().body; pm.expect(size).to.be.within(100, 5000); });
      B. pm.test('Body size limits', () => { const size = pm.response.size().body; pm.expect(size < 100 || size > 5000).to.be.false; });
      C. pm.test('Body size limits', () => { const size = pm.response.size().body; pm.expect(size).to.be.above(100) && pm.expect(size).to.be.below(5000); });
      D. pm.test('Body size limits', () => { const size = pm.response.size().body; if(size < 100 || size > 5000) { throw new Error('Body size out of limits'); } });

      Solution

      1. Step 1: Understand the requirement

        The test should fail if size is less than 100 or greater than 5000 bytes.
      2. Step 2: Evaluate each option's logic

        pm.test('Body size limits', () => { const size = pm.response.size().body; pm.expect(size).to.be.within(100, 5000); }); uses within(100, 5000) which includes 100 and 5000, but does not fail outside range explicitly.
        pm.test('Body size limits', () => { const size = pm.response.size().body; pm.expect(size < 100 || size > 5000).to.be.false; }); uses a boolean expression inside pm.expect() which is not a valid assertion.
        pm.test('Body size limits', () => { const size = pm.response.size().body; pm.expect(size).to.be.above(100) && pm.expect(size).to.be.below(5000); }); uses two assertions combined with && which does not work as expected in Postman.
        pm.test('Body size limits', () => { const size = pm.response.size().body; if(size < 100 || size > 5000) { throw new Error('Body size out of limits'); } }); throws an error explicitly if size is out of limits, causing the test to fail correctly.
      3. Final Answer:

        Option D correctly fails the test when size is out of limits -> Option D
      4. Quick Check:

        Throw error to fail test on condition [OK]
      Hint: Use throw Error to fail test on size limits [OK]
      Common Mistakes:
      • Using invalid assertion syntax for range checks
      • Combining assertions incorrectly with &&
      • Not explicitly failing test on condition
      Recommended

      Ready to prove it?

      Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

      10 questions~5 mineasy hard