Challenge - 5 Problems
Status Code Assertion Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ assertion
intermediate2: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?
Attempts:
2 left
💡 Hint
Use the Postman built-in assertion syntax for status codes.
✗ Incorrect
Option D uses the correct Postman Chai assertion syntax to check the response status code equals 200. Other options either use incorrect properties or methods.
❓ assertion
intermediate2:00remaining
Assert status code is in 2xx range
Which Postman test code correctly asserts that the response status code is any 2xx success code?
Attempts:
2 left
💡 Hint
Use numeric range assertions with pm.expect.
✗ Incorrect
Option A correctly uses pm.expect with .to.be.within(200, 299) to check the status code range. Option A lacks an assertion, B uses invalid syntax, and C uses pm.response.status which is a string, not a number.
❓ Predict Output
advanced2: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); });
Attempts:
2 left
💡 Hint
The assertion expects exactly 200 but response is 404.
✗ Incorrect
The test checks for status 200 but the response is 404, so the assertion fails and the test fails.
🔧 Debug
advanced2: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; });
Attempts:
2 left
💡 Hint
Check the syntax for calling assertion methods.
✗ Incorrect
The code uses '==' which compares but does not call the assertion method. The assertion must be called as a function with parentheses.
🧠 Conceptual
expert2:00remaining
Understanding status code assertion behavior in Postman
Which statement best describes how Postman handles status code assertions in tests?
Attempts:
2 left
💡 Hint
Think about how assertion libraries work in Postman tests.
✗ Incorrect
Postman uses Chai.js assertion library. If a status code assertion fails, the test fails immediately. Postman does not retry or ignore assertions based on response body.