0
0
Postmantesting~10 mins

Using Chai assertion library 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 that 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'
A200
B404
C500
D201
Attempts:
3 left
💡 Hint
Common Mistakes
Using a wrong status code like 404 or 500.
Forgetting to put the status code as a number.
2fill in blank
medium

Complete the code to assert that the response body contains the string 'success'.

Postman
pm.test('Body contains success', function () {
    pm.expect(pm.response.text()).to.include([1]);
});
Drag options to blanks, or click blank then click option'
A'fail'
B'error'
C'success'
D'warning'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a word that does not appear in the response.
Not using quotes around the string.
3fill in blank
hard

Fix the error in the assertion to check that the JSON response has a property 'id'.

Postman
pm.test('Response has id property', function () {
    pm.expect(pm.response.json()).to.have.[1]('id');
});
Drag options to blanks, or click blank then click option'
Alength
Bstatus
Cinclude
Dproperty
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'length' which checks array size, not property existence.
Using 'status' which is unrelated here.
4fill in blank
hard

Fill both blanks to assert that the response JSON array length is greater than 0.

Postman
pm.test('Array length is positive', function () {
    pm.expect(pm.response.json().length).to.be.[1](0).[2](0);
});
Drag options to blanks, or click blank then click option'
AgreaterThan
Babove
Cbelow
Dequal
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'below' or 'equal' which check wrong conditions.
Mixing the order of chaining words.
5fill in blank
hard

Fill all three blanks to assert that the response JSON object's 'name' property equals 'John'.

Postman
pm.test('Name is John', function () {
    pm.expect(pm.response.json().[1]).[2].[3]('John');
});
Drag options to blanks, or click blank then click option'
Aname
Bequal
Cto
Dstatus
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong property name.
Mixing the order of chaining words.
Using 'status' instead of 'equal'.