What is the main purpose of defining mock responses in Postman?
Think about why you might want to test an API before it is ready or available.
Mock responses let you simulate how an API would respond without needing the real backend. This helps in early testing and development.
Given this Postman mock response setup, what will be the HTTP status code returned when the mock is called?
{
"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"}]
}
}Look at the status field inside the response object.
The mock response is configured with status 200, so calling this mock will return HTTP 200 OK.
Which Postman test script assertion correctly verifies that the mock response body contains the user's name as 'Alice'?
pm.test("User name is Alice", () => {
const jsonData = pm.response.json();
// Which assertion goes here?
});Check the property that holds the user's name and compare it to 'Alice'.
The correct assertion checks that the name property in the JSON response equals 'Alice'.
What error will occur when this Postman mock response is called?
{
"name": "Invalid Mock",
"request": {
"method": "POST",
"url": "/submit"
},
"response": {
"status": "two hundred",
"body": "Success",
"headers": [{"key": "Content-Type", "value": "text/plain"}]
}
}Check the data type of the status field.
The status code must be a number. Using a string like 'two hundred' causes a runtime error when Postman tries to send the response.
Which option describes the best practice to ensure Postman mock server returns the correct response when multiple mocks have similar request URLs?
Think about how Postman decides which mock response to send when requests are similar.
Postman matches mocks based on HTTP method and exact URL path including query parameters to ensure the correct response is returned.