0
0
Postmantesting~10 mins

Nested object assertions 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 assert the 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 201 or 404.
Forgetting to put the status code inside the parentheses.
2fill in blank
medium

Complete the code to assert the response JSON has a nested property 'user.name'.

Postman
pm.test('Response has user name', function () { pm.expect(pm.response.json()).to.have.nested.property([1]); });
Drag options to blanks, or click blank then click option'
A'user.name'
B'username'
C'userName'
D'user-name'
Attempts:
3 left
💡 Hint
Common Mistakes
Using camelCase or hyphen instead of dot notation.
Not putting the property name inside quotes.
3fill in blank
hard

Fix the error in the assertion to check that 'data.items[0].id' equals 123.

Postman
pm.test('First item id is 123', function () { pm.expect(pm.response.json()).to.have.nested.property('data.items[0].id', [1]); });
Drag options to blanks, or click blank then click option'
A'123'
B123
C"123"
D'id'
Attempts:
3 left
💡 Hint
Common Mistakes
Using quotes around 123 making it a string.
Using the property name instead of the expected value.
4fill in blank
hard

Fill both blanks to assert the nested property 'profile.address.city' equals 'New York'.

Postman
pm.test('City is New York', function () { pm.expect(pm.response.json()).to.have.nested.property([1], [2]); });
Drag options to blanks, or click blank then click option'
A'profile.address.city'
B'New York'
C'Los Angeles'
D'profile.city'
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect nested path like 'profile.city'.
Using wrong city name or missing quotes.
5fill in blank
hard

Fill all three blanks to assert the nested property 'order.items[1].price' is greater than 20.

Postman
pm.test('Second item price check', function () { pm.expect(pm.response.json()).to.have.nested.property([1]); pm.expect(pm.response.json().order.items[1].price).to.be.[2]([3]); });
Drag options to blanks, or click blank then click option'
A'order.items[1].price'
Babove
C20
Dequal
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'equal' instead of 'above' for greater than check.
Not using quotes for the nested property path.
Using string '20' instead of number 20.