0
0
Postmantesting~10 mins

Mock server limitations in Postman - Interactive Code Practice

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

Complete 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'
A200
Bresponse
Csend
Dmock
Attempts:
3 left
💡 Hint
Common Mistakes
Using a string instead of a number for status code.
Using method names instead of status codes.
2fill in blank
medium

Complete 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'
AContent-Type
BAuthorization
CAccept
DUser-Agent
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'Authorization' instead of 'Content-Type' for data format.
Misspelling header names.
3fill in blank
hard

Fix the error in the mock server response body assignment.

Postman
pm.mockResponse.setBody([1]);
Drag options to blanks, or click blank then click option'
Amessage: 'Success'
B{"message": "Success"}
C['message', 'Success']
D'{"message": "Success"}'
Attempts:
3 left
💡 Hint
Common Mistakes
Passing an object directly instead of a string.
Using invalid JSON format.
4fill in blank
hard

Fill 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'
AisEnabled
Bstart
Cstop
DisRunning
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'stop' instead of 'start' to run the mock.
Using 'isRunning' which is not a valid method.
5fill in blank
hard

Fill 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'
A404
BContent-Type
C'{"error": "Not Found"}'
D200
Attempts:
3 left
💡 Hint
Common Mistakes
Using 200 status instead of 404.
Passing body as an object instead of a string.
Misspelling header name.