Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to set the mock server response status code.
Postman
pm.mockResponse.setStatus([1]); Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a string instead of a number for status code.
Using method names instead of status codes.
✗ Incorrect
The status code must be a number like 200 to indicate success.
2fill in blank
mediumComplete the code to set a mock server response header.
Postman
pm.mockResponse.setHeader('[1]', 'application/json');
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'Authorization' instead of 'Content-Type' for data format.
Misspelling header names.
✗ Incorrect
The 'Content-Type' header tells the client the data format, here JSON.
3fill in blank
hardFix the error in the mock server response body assignment.
Postman
pm.mockResponse.setBody([1]); Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Passing an object directly instead of a string.
Using invalid JSON format.
✗ Incorrect
The body must be a string, so JSON must be inside quotes.
4fill in blank
hardFill both blanks to correctly check if the mock server is enabled and then start it.
Postman
if (pm.mockResponse.[1]()) { pm.mockResponse.[2](); }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'stop' instead of 'start' to run the mock.
Using 'isRunning' which is not a valid method.
✗ Incorrect
Use isEnabled() to check if mock is active, then start() to run it.
5fill in blank
hardFill all three blanks to set a mock response with status 404, a JSON content type header, and a body message.
Postman
pm.mockResponse.setStatus([1]); pm.mockResponse.setHeader('[2]', 'application/json'); pm.mockResponse.setBody([3]);
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 200 status instead of 404.
Passing body as an object instead of a string.
Misspelling header name.
✗ Incorrect
Use status 404 for not found, set 'Content-Type' header, and provide JSON string body.