0
0
Postmantesting~10 mins

Why automated assertions validate responses in Postman - Test Your Understanding

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

Complete the code to check if the response status 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'
A201
B500
C404
D200
Attempts:
3 left
💡 Hint
Common Mistakes
Using a wrong status code like 201 or 404.
Forgetting to put the status code inside the assertion.
2fill in blank
medium

Complete the code to assert the response body contains the key 'success'.

Postman
pm.test("Response has success key", function () { pm.expect(pm.response.json()).to.have.property([1]); });
Drag options to blanks, or click blank then click option'
A"success"
B"message"
C"status"
D"error"
Attempts:
3 left
💡 Hint
Common Mistakes
Using keys that do not exist in the response.
Forgetting to put the key name in quotes.
3fill in blank
hard

Fix the error in the assertion that checks if the response time is less than 200ms.

Postman
pm.test("Response time is fast", function () { pm.expect(pm.response.responseTime).to.be.[1](200); });
Drag options to blanks, or click blank then click option'
Abelow
BlessThan
Cabove
DgreaterThan
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'below' which is not a valid method.
Using 'greaterThan' which checks the opposite condition.
4fill in blank
hard

Fill both blanks to assert the response header 'Content-Type' is 'application/json'.

Postman
pm.test("Content-Type is JSON", function () { pm.response.to.have.header([1]); pm.expect(pm.response.headers.get([2])).to.equal('application/json'); });
Drag options to blanks, or click blank then click option'
A"Content-Type"
B"Accept"
C"content-type"
D"Authorization"
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong header names like 'Accept' or 'Authorization'.
Using different header names in the two blanks.
5fill in blank
hard

Fill all three blanks to assert the response JSON has a 'data' object with a 'userId' equal to 5.

Postman
pm.test("User ID is 5", function () { const jsonData = pm.response.json(); pm.expect(jsonData[1][2]).to.eql([3]); });
Drag options to blanks, or click blank then click option'
A['data']
B['userId']
C5
D['id']
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong keys like 'id' instead of 'userId'.
Checking for wrong values instead of 5.