Challenge - 5 Problems
Postman Output Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
What is the output of this Postman test script?
Consider this Postman test script that checks the response status and sets a variable. What will be the value of the variable
isSuccess after running this test if the response status is 200?Postman
pm.test("Status code is 200", function () { pm.response.to.have.status(200); pm.variables.set("isSuccess", true); });
Attempts:
2 left
💡 Hint
Think about what happens when the status code matches 200 in the test.
✗ Incorrect
The test checks if the response status is 200. If true, it sets the variable isSuccess to true. Since the response status is 200, the variable is set.
❓ assertion
intermediate2:00remaining
Which assertion correctly verifies the JSON response contains a key 'userId' with value 5?
You want to assert that the JSON response body has a key 'userId' equal to 5. Which Postman test assertion is correct?
Postman
const jsonData = pm.response.json();
Attempts:
2 left
💡 Hint
Look for the assertion that checks equality to 5.
✗ Incorrect
Option A correctly asserts that jsonData.userId equals 5. Other options check for undefined, greater than 5, or not equal to 5, which are incorrect.
🔧 Debug
advanced2:00remaining
Why does this Postman test script fail with a ReferenceError?
Examine the test script below. Why does it throw a ReferenceError when run?
Postman
pm.test("Check user name", function () { pm.expect(user.name).to.eql("Alice"); });
Attempts:
2 left
💡 Hint
Check if the variable 'user' is declared or assigned.
✗ Incorrect
The script uses 'user' without defining it. This causes a ReferenceError. The correct approach is to parse the response JSON first.
❓ framework
advanced2:00remaining
Which Postman test script correctly waits for an asynchronous fetch before asserting?
You want to fetch additional data asynchronously inside a test and then assert a value. Which script correctly handles the async operation?
Attempts:
2 left
💡 Hint
Remember that async functions need to be awaited or handled with promises properly.
✗ Incorrect
Option C uses async/await correctly inside the test function. Option C does not wait for the promise to resolve before ending the test. Options C and D misuse fetch and json() without awaiting promises.
🧠 Conceptual
expert2:00remaining
What is the main purpose of the Postman 'Tests' output block?
In Postman, the 'Tests' output block shows results after running a request. What is its main purpose?
Attempts:
2 left
💡 Hint
Think about what you see after tests run in Postman.
✗ Incorrect
The 'Tests' output block shows which tests passed or failed and any messages from assertions. It does not show request headers, edit bodies, or configure variables.