Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to create a mock server in Postman.
Postman
pm.mockServer.create([1]: 'My Mock Server'});
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'url' instead of 'name' causes an error.
Confusing 'method' with server creation property.
✗ Incorrect
The name property is required to create a mock server in Postman.
2fill in blank
mediumComplete the code to define a mock response for a GET request.
Postman
pm.mockServer.addMockResponse({ method: 'GET', [1]: '/users', response: { status: 200, body: '{}' } }); Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'url' instead of 'path' causes the mock to not match requests.
Confusing 'endpoint' with the property name.
✗ Incorrect
The path property defines the endpoint path for the mock response.
3fill in blank
hardFix the error in the mock response code to enable parallel development.
Postman
pm.mockServer.addMockResponse({ method: 'POST', path: '/login', response: { status: 200, body: [1] } }); Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Passing an object instead of a JSON string causes runtime errors.
Missing quotes around the JSON string.
✗ Incorrect
The body must be a JSON string, so it needs to be properly quoted and escaped.
4fill in blank
hardFill both blanks to create a mock server and add a mock response for GET /products.
Postman
const mockServer = pm.mockServer.[1]([2]: 'Product Mock Server'}); mockServer.addMockResponse({ method: 'GET', path: '/products', response: { status: 200, body: '{}' } });
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'start' instead of 'create' causes errors.
Using 'url' instead of 'name' for server creation.
✗ Incorrect
Use create to make the mock server and set its name.
5fill in blank
hardFill all three blanks to define a mock response with status 404 and a JSON error message.
Postman
mockServer.addMockResponse({ method: [1], path: [2], response: { status: [3], body: '{"error": "Not Found"}' } }); Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong method string causes mock mismatch.
Incorrect status code changes the test meaning.
✗ Incorrect
The mock response uses method 'GET', path '/unknown', and status 404 to simulate a not found error.