Bird
Raised Fist0
Postmantesting~10 mins

Response time benchmarking in Postman - Interactive Code Practice

Choose your learning style10 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to get the response time of the API call.

Postman
pm.test('Response time is recorded', function () {
    var responseTime = pm.response.[1];
    pm.expect(responseTime).to.be.a('number');
});
Drag options to blanks, or click blank then click option'
AresponseTime
BresponseTimeMs
CresponseTimeInMs
DresponseTimeDuration
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect property names like responseTimeMs or responseTimeInMs.
2fill in blank
medium

Complete the code to assert the response time is less than 200 milliseconds.

Postman
pm.test('Response time is under 200ms', function () {
    pm.expect(pm.response.[1]).to.be.below(200);
});
Drag options to blanks, or click blank then click option'
AelapsedTime
BresponseTime
Cduration
Dtime
Attempts:
3 left
💡 Hint
Common Mistakes
Using properties that do not exist on the response object.
3fill in blank
hard

Fix the error in the code to correctly log the response time.

Postman
console.log('Response time:', pm.response.[1] + 'ms');
Drag options to blanks, or click blank then click option'
Atime
Bduration
CresponseTime
Delapsed
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect or non-existent property names.
4fill in blank
hard

Fill both blanks to create a test that fails if response time exceeds 500ms.

Postman
pm.test('Response time check', function () {
    pm.expect(pm.response.[1]).to.be.[2](500);
});
Drag options to blanks, or click blank then click option'
AresponseTime
Bbelow
Cabove
Dequal
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'above' instead of 'below' for the assertion.
5fill in blank
hard

Fill all three blanks to create a test that logs response time and asserts it is less than 300ms.

Postman
pm.test('Response time logging and check', function () {
    var time = pm.response.[1];
    console.log('Response time:', time + '[2]');
    pm.expect(time).to.be.[3](300);
});
Drag options to blanks, or click blank then click option'
AresponseTime
Bms
Cbelow
Dmilliseconds
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong property names or assertion methods.
Using 'milliseconds' string instead of 'ms' for logging.

Practice

(1/5)
1. What does pm.response.responseTime measure in Postman?
easy
A. The time taken by the server to respond to a request
B. The size of the response body
C. The number of requests sent
D. The status code of the response

Solution

  1. Step 1: Understand the purpose of pm.response.responseTime

    This property records how long the server takes to send back a response after a request is made.
  2. Step 2: Differentiate from other response properties

    It does not measure response size, count requests, or check status codes; it only measures response speed.
  3. Final Answer:

    The time taken by the server to respond to a request -> Option A
  4. Quick Check:

    Response time = server speed [OK]
Hint: Response time means how fast server replies [OK]
Common Mistakes:
  • Confusing response time with response size
  • Thinking it counts requests instead of timing
  • Mixing it up with status code checks
2. Which of the following is the correct way to assert that response time is less than 500 milliseconds in Postman test script?
easy
A. pm.test('Response time is less than 500ms', () => pm.expect(pm.response.responseTime).to.equal(500));
B. pm.test('Response time is less than 500ms', () => pm.response.responseTime < 500);
C. pm.test('Response time is less than 500ms', () => pm.response.responseTime > 500);
D. pm.test('Response time is less than 500ms', () => pm.expect(pm.response.responseTime).to.be.below(500));

Solution

  1. Step 1: Identify correct assertion syntax in Postman

    Postman uses Chai assertion library syntax: pm.expect(value).to.be.below(limit) to check if value is less than limit.
  2. Step 2: Check each option's logic and syntax

    pm.test('Response time is less than 500ms', () => pm.expect(pm.response.responseTime).to.be.below(500)); correctly uses pm.expect(pm.response.responseTime).to.be.below(500). pm.test('Response time is less than 500ms', () => pm.response.responseTime < 500); lacks assertion method. The version checking greater than 500 reverses the logic, and the version checking equality to 500 uses the wrong matcher.
  3. Final Answer:

    pm.test('Response time is less than 500ms', () => pm.expect(pm.response.responseTime).to.be.below(500)); -> Option D
  4. Quick Check:

    Use pm.expect(...).to.be.below(...) for less than checks [OK]
Hint: Use pm.expect(...).to.be.below(value) for less than checks [OK]
Common Mistakes:
  • Using comparison operators without pm.expect
  • Checking for equality instead of less than
  • Reversing comparison logic
3. Given this Postman test script snippet:
pm.test('Check response time', () => {
  pm.expect(pm.response.responseTime).to.be.below(300);
});

If the actual response time is 350 ms, what will be the test result?
medium
A. Test fails because 350 is not below 300
B. Test passes because 350 is below 300
C. Test passes because response time is ignored
D. Test throws a syntax error

Solution

  1. Step 1: Understand the assertion condition

    The test expects response time to be less than 300 ms using to.be.below(300).
  2. Step 2: Compare actual response time with expected limit

    The actual response time is 350 ms, which is greater than 300 ms, so the assertion fails.
  3. Final Answer:

    Test fails because 350 is not below 300 -> Option A
  4. Quick Check:

    350 > 300 means assertion fails [OK]
Hint: If actual > limit, test fails for 'to.be.below' [OK]
Common Mistakes:
  • Thinking 350 is less than 300
  • Assuming test passes without checking values
  • Confusing syntax error with assertion failure
4. You wrote this Postman test to check response time:
pm.test('Response time under 200ms', () => {
  pm.expect(pm.response.responseTime).below(200);
});

But the test always passes even when response time is 500 ms. What is the error?
medium
A. Response time property is misspelled
B. Using pm.expect incorrectly without parentheses
C. Missing to.be before below(200)
D. Test name is incorrect

Solution

  1. Step 1: Check assertion syntax correctness

    The correct Chai syntax requires chaining to.be.below(200). The code uses pm.expect(...).below(200) missing to.be.
  2. Step 2: Understand effect of missing chain

    Without to.be, the assertion does not execute properly and silently passes, ignoring the actual response time.
  3. Final Answer:

    Missing to.be before below(200) -> Option C
  4. Quick Check:

    Use full chain pm.expect(...).to.be.below(...) [OK]
Hint: Always use pm.expect(...).to.be.below(...) chain [OK]
Common Mistakes:
  • Omitting 'to.be' in assertion chain
  • Misspelling responseTime property
  • Ignoring test failure due to syntax
5. You want to benchmark response times for multiple API endpoints in Postman and fail the test if any response time exceeds 400 ms. Which approach is best?
hard
A. Write a test script in each request using pm.expect(pm.response.responseTime).to.be.below(400)
B. Use a collection-level test script that checks pm.response.responseTime after each request
C. Manually check response times in Postman console after running all requests
D. Set a global variable with response time and compare after all requests finish

Solution

  1. Step 1: Understand scope of test scripts in Postman

    Collection-level scripts run after every request in the collection, allowing centralized checks for all endpoints.
  2. Step 2: Compare options for efficiency and automation

    Use a collection-level test script that checks pm.response.responseTime after each request automates response time checks for all requests without repeating code. Writing a test script in each request using pm.expect(pm.response.responseTime).to.be.below(400) duplicates code, manually checking response times in Postman console after running all requests is error-prone, and setting a global variable with response time and comparing after all requests finish complicates logic unnecessarily.
  3. Final Answer:

    Use a collection-level test script that checks pm.response.responseTime after each request -> Option B
  4. Quick Check:

    Collection-level scripts automate checks for all requests [OK]
Hint: Use collection-level tests to check all response times automatically [OK]
Common Mistakes:
  • Repeating same test in every request script
  • Relying on manual checking instead of automation
  • Overcomplicating with global variables
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