0
0
Postmantesting~10 mins

Using mock server URL 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 URL in Postman.

Postman
pm.environment.set('baseUrl', '[1]');
Drag options to blanks, or click blank then click option'
Ahttps://mockserver.example.com
Blocalhost:3000
Chttp://api.example.com
Dftp://mockserver
Attempts:
3 left
💡 Hint
Common Mistakes
Using localhost or non-HTTPS URLs for the mock server.
Using the real API URL instead of the mock server URL.
2fill in blank
medium

Complete the code to send a GET request to the mock server URL stored in environment variable.

Postman
pm.sendRequest(pm.environment.get('[1]') + '/users', function (err, res) { pm.test('Status is 200', function () { pm.expect(res).to.have.property('statusCode', 200); }); });
Drag options to blanks, or click blank then click option'
AmockUrl
BserverUrl
CapiUrl
DbaseUrl
Attempts:
3 left
💡 Hint
Common Mistakes
Using a variable name that does not exist in environment variables.
Forgetting to add the endpoint path after the base URL.
3fill in blank
hard

Fix the error in the test script to correctly check the response status code from the mock server.

Postman
pm.test('Response status is 200', function () { pm.expect(res.[1]).to.eql(200); });
Drag options to blanks, or click blank then click option'
Acode
BstatusCode
Cstatus
Dstatus_code
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'res.status' or 'res.code' which are undefined in Postman response object.
Using snake_case instead of camelCase for property names.
4fill in blank
hard

Fill both blanks to create a test that checks the response body has a 'message' property equal to 'Success'.

Postman
pm.test('Body has success message', function () { pm.expect(res.[1]).to.have.property('[2]', 'Success'); });
Drag options to blanks, or click blank then click option'
Ajson()
Btext()
Cmessage
Dbody
Attempts:
3 left
💡 Hint
Common Mistakes
Using res.body instead of res.json() to access JSON properties.
Checking for wrong property names or values.
5fill in blank
hard

Fill all three blanks to write a test that verifies the response header 'Content-Type' includes 'application/json'.

Postman
pm.test('Content-Type is JSON', function () { pm.expect(res.[1].get('[2]')).to.include('[3]'); });
Drag options to blanks, or click blank then click option'
Aheaders
Bheader
CContent-Type
Dapplication/json
Attempts:
3 left
💡 Hint
Common Mistakes
Using res.headers.get instead of res.header.get.
Checking for wrong header names or exact match instead of includes.