0
0
Postmantesting~20 mins

Send request block in Postman - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Postman Request Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
What is the result of this Postman test script?

Given this Postman test script inside the Tests tab, what will be the test result after sending the request?

Postman
pm.test("Status code is 200", function () {
    pm.response.to.have.status(200);
});
pm.test("Response has userId", function () {
    const jsonData = pm.response.json();
    pm.expect(jsonData).to.have.property('userId');
});
ABoth tests pass if the response status is 200 and JSON contains 'userId' property.
BThe tests pass regardless of response content or status.
CBoth tests fail if the response is not JSON format.
DThe first test fails if status is 200; the second test always passes.
Attempts:
2 left
💡 Hint

Check the response status and JSON structure before running tests.

assertion
intermediate
1:30remaining
Which assertion correctly checks that response time is less than 500ms?

Choose the Postman test assertion that will pass only if the response time is under 500 milliseconds.

Apm.test('Response time is less than 500ms', () => { pm.expect(pm.response.time).to.be.below(500); });
Bpm.test('Response time is less than 500ms', () => { pm.expect(pm.response.responseTime).to.be.above(500); });
Cpm.test('Response time is less than 500ms', () => { pm.expect(pm.response.responseTime).to.be.below(500); });
Dpm.test('Response time is less than 500ms', () => { pm.expect(pm.response.responseTime).to.equal(500); });
Attempts:
2 left
💡 Hint

Look for the property that holds response time in milliseconds and the correct comparison.

locator
advanced
2:00remaining
Which Postman test code correctly extracts the 'token' from a nested JSON response?

Given this JSON response:

{
  "data": {
    "auth": {
      "token": "abc123xyz"
    }
  }
}

Which code snippet correctly saves the token value into a variable?

Aconst token = pm.response.json().auth.token;
Bconst token = pm.response.json().data.auth.token;
Cconst token = pm.response.json().data.token;
Dconst token = pm.response.json().token;
Attempts:
2 left
💡 Hint

Follow the JSON structure step-by-step to reach the token.

🔧 Debug
advanced
2:00remaining
Why does this Postman test script throw an error?

Consider this test script:

pm.test('Check user name', () => {
  const jsonData = pm.response.json;
  pm.expect(jsonData.name).to.eql('Alice');
});

What causes the error during execution?

Apm.response.json is a function and must be called with parentheses.
Bpm.expect cannot compare strings with to.eql.
CThe property 'name' does not exist in the response.
Dpm.test requires a callback with no parameters.
Attempts:
2 left
💡 Hint

Check how to properly parse JSON response in Postman scripts.

framework
expert
3:00remaining
Which Postman test script block correctly runs multiple tests and reports all failures?

You want to run these tests in Postman and see all failures reported, not just stop at the first failure:

  • Status code is 200
  • Response time is less than 300ms
  • Response body contains 'success'

Which code block achieves this?

A
pm.test('Status code is 200', () => { pm.response.to.have.status(200); });
pm.test('Response time < 300ms', () => { pm.expect(pm.response.responseTime).to.be.above(300); });
pm.test('Body contains success', () => { pm.expect(pm.response.text()).to.include('success'); });
B
pm.test('All checks', () => {
  pm.response.to.have.status(200);
  pm.expect(pm.response.responseTime).to.be.below(300);
  pm.expect(pm.response.text()).to.include('success');
});
C
pm.test('All checks', () => {
  if(pm.response.code !== 200) throw new Error('Status code not 200');
  if(pm.response.responseTime >= 300) throw new Error('Response time too high');
  if(!pm.response.text().includes('success')) throw new Error('Missing success in body');
});
D
pm.test('Status code is 200', () => { pm.response.to.have.status(200); });
pm.test('Response time < 300ms', () => { pm.expect(pm.response.responseTime).to.be.below(300); });
pm.test('Body contains success', () => { pm.expect(pm.response.text()).to.include('success'); });
Attempts:
2 left
💡 Hint

Separate tests allow reporting all failures individually.