0
0
Postmantesting~20 mins

Status code assertion in Postman - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Status Code Assertion Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
assertion
intermediate
2:00remaining
Check for successful status code 200
You want to write a Postman test to verify the response status code is exactly 200. Which code snippet correctly asserts this?
Apm.test('Status code is 200', () => { pm.response.statusCode(200); });
Bpm.test('Status code is 200', () => { pm.response.to.be.status(200); });
Cpm.test('Status code is 200', () => { pm.response.status === 200; });
Dpm.test('Status code is 200', () => { pm.response.to.have.status(200); });
Attempts:
2 left
💡 Hint
Use the Postman built-in assertion syntax for status codes.
assertion
intermediate
2:00remaining
Assert status code is in 2xx range
Which Postman test code correctly asserts that the response status code is any 2xx success code?
Apm.test('Status code is 2xx', () => { pm.expect(pm.response.code).to.be.within(200, 299); });
Bpm.test('Status code is 2xx', () => { pm.response.to.have.status(2xx); });
Cpm.test('Status code is 2xx', () => { pm.expect(pm.response.status).to.be.above(199).and.below(300); });
Dpm.test('Status code is 2xx', () => { pm.response.statusCode >= 200 && pm.response.statusCode < 300; });
Attempts:
2 left
💡 Hint
Use numeric range assertions with pm.expect.
Predict Output
advanced
2:00remaining
Identify the test result for status code assertion
Given this Postman test code and a response with status code 404, what will be the test result?
Postman
pm.test('Status code is 200', () => { pm.response.to.have.status(200); });
ATest fails because the response status is 404, not 200.
BTest passes because 404 is a valid HTTP status code.
CTest throws a runtime error due to invalid assertion syntax.
DTest is skipped because status code assertions only run on 2xx codes.
Attempts:
2 left
💡 Hint
The assertion expects exactly 200 but response is 404.
🔧 Debug
advanced
2:00remaining
Find the error in this status code assertion
This Postman test code is intended to check for status 201 but it does not work as expected. What is the error?
Postman
pm.test('Status code is 201', () => { pm.response.to.have.status == 201; });
AThe status code 201 is invalid for HTTP responses.
BUsing '==' instead of calling the function causes no assertion to run.
Cpm.response.to.have.status requires a string, not a number.
DThe test should use pm.expect instead of pm.response.
Attempts:
2 left
💡 Hint
Check the syntax for calling assertion methods.
🧠 Conceptual
expert
2:00remaining
Understanding status code assertion behavior in Postman
Which statement best describes how Postman handles status code assertions in tests?
APostman automatically retries requests if status code assertions fail.
BStatus code assertions in Postman only check if the code is a string, not a number.
CPostman assertions for status codes use Chai.js syntax and fail the test if the assertion is false.
DPostman ignores status code assertions if the response body is empty.
Attempts:
2 left
💡 Hint
Think about how assertion libraries work in Postman tests.