0
0
Postmantesting~10 mins

Status code assertion 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 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'
A201
B404
C500
D200
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 the response status code is 404.

Postman
pm.test("Status code is 404", function () {
    pm.response.to.have.status([1]);
});
Drag options to blanks, or click blank then click option'
A404
B200
C500
D301
Attempts:
3 left
💡 Hint
Common Mistakes
Confusing 404 with 200 or 500.
Using string instead of number for status code.
3fill in blank
hard

Fix the error in the code to correctly assert status code 201.

Postman
pm.test("Status code is 201", function () {
    pm.response.to.have.status([1]);
});
Drag options to blanks, or click blank then click option'
A202
B201
C"201"
D200
Attempts:
3 left
💡 Hint
Common Mistakes
Using quotes around the status code number.
Using a wrong status code like 200 or 202.
4fill in blank
hard

Fill both blanks to assert the status code is greater than or equal to 200.

Postman
pm.test("Status code is success range", function () {
    pm.expect(pm.response.code).to.be.[1]([2]);
});
Drag options to blanks, or click blank then click option'
Aat.least
Bat.most
Cequal
D200
Attempts:
3 left
💡 Hint
Common Mistakes
Using equal instead of range checks.
Using wrong comparison methods like at.most with 200.
5fill in blank
hard

Fill all three blanks to assert the status code is between 200 and 299 inclusive.

Postman
pm.test("Status code is 2xx", function () {
    pm.expect(pm.response.code).to.be.[1]([2]);
    pm.expect(pm.response.code).to.be.[3](299);
});
Drag options to blanks, or click blank then click option'
Aat.least
B200
Cat.most
Dequal
Attempts:
3 left
💡 Hint
Common Mistakes
Using equal instead of range checks.
Mixing up at.least and at.most.