0
0
Postmantesting~10 mins

Test utilities and helpers 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 a test variable named 'userId' with value 123.

Postman
pm.environment.set('[1]', 123);
Drag options to blanks, or click blank then click option'
Aresponse
Bstatus
CuserId
Dtoken
Attempts:
3 left
💡 Hint
Common Mistakes
Using a wrong variable name like 'response' or 'status' instead of 'userId'.
Forgetting to put the variable name as a string.
2fill in blank
medium

Complete the code to check if the response status code is 200.

Postman
pm.test('Status code is 200', function () { pm.response.to.have.status([1]); });
Drag options to blanks, or click blank then click option'
A200
B500
C404
D201
Attempts:
3 left
💡 Hint
Common Mistakes
Using a wrong status code like 404 or 500.
Putting the status code in quotes which is not required.
3fill in blank
hard

Fix the error in the code to parse JSON response body correctly.

Postman
let data = pm.response.[1]();
Drag options to blanks, or click blank then click option'
Aparse
Btext
Cbody
Djson
Attempts:
3 left
💡 Hint
Common Mistakes
Using text() which returns a string, not parsed JSON.
Trying to use parse() which is not a method of pm.response.
4fill in blank
hard

Fill both blanks to write a test that checks if the response body has a property 'success' equal to true.

Postman
pm.test('Response has success true', function () { pm.expect(pm.response.[1]()).to.have.property('[2]', true); });
Drag options to blanks, or click blank then click option'
Ajson
Btext()
Csuccess
Dstatus
Attempts:
3 left
💡 Hint
Common Mistakes
Using text() instead of json() for parsing.
Checking wrong property name like 'status' instead of 'success'.
5fill in blank
hard

Fill all three blanks to write a test that checks if the response header 'Content-Type' includes 'json'.

Postman
pm.test('Content-Type is JSON', function () { pm.expect(pm.response.headers.get('[1]')).to.[2]('[3]'); });
Drag options to blanks, or click blank then click option'
AContent-Type
Binclude
Cjson
Dstatus
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong header name like 'status'.
Using wrong matcher like 'be' instead of 'include'.
Checking for wrong string instead of 'json'.