0
0
Postmantesting~10 mins

Creating mock servers in Postman - Interactive Practice

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

Complete the code to create a mock server in Postman using the correct method.

Postman
pm.mockServer.[1]({ url: 'https://api.example.com', name: 'Test Mock' });
Drag options to blanks, or click blank then click option'
Acreate
Bdelete
Cupdate
Dfetch
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'delete' instead of 'create' will try to remove a server.
Using 'fetch' is for getting data, not creating.
2fill in blank
medium

Complete the code to set the mock server's environment variable correctly.

Postman
pm.environment.set('[1]', 'mock_server_id');
Drag options to blanks, or click blank then click option'
AmockServerUrl
BmockUrl
CserverName
DmockServerId
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'mockServerUrl' stores the URL, not the ID.
Using 'serverName' is not specific enough.
3fill in blank
hard

Fix the error in the code to correctly send a mock response with status 200.

Postman
pm.mockServer.sendResponse({ status: [1], body: { message: 'Success' } });
Drag options to blanks, or click blank then click option'
A'OK'
B'200'
C200
Dtrue
Attempts:
3 left
💡 Hint
Common Mistakes
Using '200' as a string causes errors.
Using 'OK' is a status text, not a code.
4fill in blank
hard

Fill both blanks to create a mock server and assign its ID to an environment variable.

Postman
const mockServer = pm.mockServer.[1]({ url: 'https://api.test.com' });
pm.environment.set('[2]', mockServer.id);
Drag options to blanks, or click blank then click option'
Acreate
Bdelete
CmockServerId
DmockServerUrl
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'delete' instead of 'create' will remove servers.
Storing the URL instead of the ID causes confusion.
5fill in blank
hard

Fill all three blanks to define a mock response with status 201, a JSON body, and a header.

Postman
pm.mockServer.sendResponse({ status: [1], body: [2], headers: [3] });
Drag options to blanks, or click blank then click option'
A201
B{\"id\": 123, \"status\": \"created\"}
C[{ key: 'Content-Type', value: 'application/json' }]
D200
Attempts:
3 left
💡 Hint
Common Mistakes
Using status 200 instead of 201 for creation.
Not formatting headers as an array of objects.