0
0
Postmantesting~10 mins

Dynamic assertion values 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 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
B200
C404
D500
Attempts:
3 left
💡 Hint
Common Mistakes
Using a wrong status code like 201 or 404.
Forgetting to put the status code as a number.
2fill in blank
medium

Complete the code to assert the JSON response has a property 'userId' equal to 1.

Postman
pm.test("User ID is 1", function () {
    var jsonData = pm.response.json();
    pm.expect(jsonData.[1]).to.eql(1);
});
Drag options to blanks, or click blank then click option'
Aid
Buserid
Cuser_id
DuserId
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect property names like 'id' or 'userid'.
Not matching the case exactly.
3fill in blank
hard

Fix the error in the code to assert the response time is less than 500 ms.

Postman
pm.test("Response time is less than 500ms", function () {
    pm.expect(pm.response.[1]).to.be.below(500);
});
Drag options to blanks, or click blank then click option'
AresponseTime
Btime
Cduration
Delapsed
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect property names like 'time' or 'duration'.
Confusing response time with other response properties.
4fill in blank
hard

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

Postman
pm.test("Array length is greater than 3", function () {
    var jsonData = pm.response.json();
    pm.expect(jsonData.[1].[2]).to.be.above(3);
});
Drag options to blanks, or click blank then click option'
Aitems
Blength
Ccount
Dsize
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong property names like 'count' or 'size'.
Trying to check length on a non-array property.
5fill in blank
hard

Fill all three blanks to assert the response header 'Content-Type' includes 'json'.

Postman
pm.test("Content-Type header includes json", function () {
    var contentType = pm.response.headers.get('[1]');
    pm.expect(contentType.[2]('[3]')).to.be.true;
});
Drag options to blanks, or click blank then click option'
AContent-Type
Bincludes
Cjson
Dcontent-type
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong header name like 'content-type' (wrong case).
Using wrong string method like 'contains' instead of 'includes'.
Checking for wrong substring.