0
0
Postmantesting~20 mins

Defining mock responses in Postman - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Mock Response Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Purpose of Mock Responses in Postman

What is the main purpose of defining mock responses in Postman?

ATo automatically generate API documentation
BTo simulate API responses without calling the actual server
CTo deploy APIs to production environments
DTo monitor live API traffic in real-time
Attempts:
2 left
💡 Hint

Think about why you might want to test an API before it is ready or available.

Predict Output
intermediate
2:00remaining
Output of a Mock Response Setup

Given this Postman mock response setup, what will be the HTTP status code returned when the mock is called?

Postman
{
  "name": "User Info Mock",
  "request": {
    "method": "GET",
    "url": "/user/info"
  },
  "response": {
    "status": 200,
    "body": "{\"name\": \"Alice\", \"age\": 30}",
    "headers": [{"key": "Content-Type", "value": "application/json"}]
  }
}
A500
B404
C401
D200
Attempts:
2 left
💡 Hint

Look at the status field inside the response object.

assertion
advanced
2:00remaining
Correct Assertion for Mock Response Body

Which Postman test script assertion correctly verifies that the mock response body contains the user's name as 'Alice'?

Postman
pm.test("User name is Alice", () => {
  const jsonData = pm.response.json();
  // Which assertion goes here?
});
Apm.expect(jsonData.name).to.eql('Alice');
Bpm.expect(jsonData.age).to.eql('Alice');
Cpm.expect(pm.response.text()).to.include('Bob');
Dpm.expect(jsonData.name).to.be.undefined;
Attempts:
2 left
💡 Hint

Check the property that holds the user's name and compare it to 'Alice'.

🔧 Debug
advanced
2:00remaining
Identify the Error in Mock Response Setup

What error will occur when this Postman mock response is called?

Postman
{
  "name": "Invalid Mock",
  "request": {
    "method": "POST",
    "url": "/submit"
  },
  "response": {
    "status": "two hundred",
    "body": "Success",
    "headers": [{"key": "Content-Type", "value": "text/plain"}]
  }
}
ANo error, mock returns status 200 automatically
BSyntaxError due to invalid JSON format
CRuntime error because status code must be a number, not a string
DTypeError because body must be an object, not a string
Attempts:
2 left
💡 Hint

Check the data type of the status field.

framework
expert
2:00remaining
Best Practice for Mock Response Matching in Postman

Which option describes the best practice to ensure Postman mock server returns the correct response when multiple mocks have similar request URLs?

AUse exact HTTP method and URL path matching with query parameters included if needed
BDefine mocks with only the URL path and ignore HTTP methods to simplify matching
CUse random response selection to test different scenarios automatically
DCreate one mock with a wildcard URL to handle all requests
Attempts:
2 left
💡 Hint

Think about how Postman decides which mock response to send when requests are similar.