Given this Postman test script inside the Tests tab, what will be the test result after sending the request?
pm.test("Status code is 200", function () { pm.response.to.have.status(200); }); pm.test("Response has userId", function () { const jsonData = pm.response.json(); pm.expect(jsonData).to.have.property('userId'); });
Check the response status and JSON structure before running tests.
The first test checks if the HTTP status code is exactly 200. The second test parses the response as JSON and checks if the 'userId' property exists. Both must pass for the test block to pass.
Choose the Postman test assertion that will pass only if the response time is under 500 milliseconds.
Look for the property that holds response time in milliseconds and the correct comparison.
pm.response.responseTime holds the response time in milliseconds. The assertion 'to.be.below(500)' passes only if the time is less than 500ms.
Given this JSON response:
{
"data": {
"auth": {
"token": "abc123xyz"
}
}
}Which code snippet correctly saves the token value into a variable?
Follow the JSON structure step-by-step to reach the token.
The token is inside 'data' then 'auth'. So accessing pm.response.json().data.auth.token gets the correct value.
Consider this test script:
pm.test('Check user name', () => {
const jsonData = pm.response.json;
pm.expect(jsonData.name).to.eql('Alice');
});What causes the error during execution?
Check how to properly parse JSON response in Postman scripts.
pm.response.json is a function. Missing parentheses means jsonData is a function reference, not the parsed object, causing an error when accessing jsonData.name.
You want to run these tests in Postman and see all failures reported, not just stop at the first failure:
- Status code is 200
- Response time is less than 300ms
- Response body contains 'success'
Which code block achieves this?
Separate tests allow reporting all failures individually.
Option D runs three separate tests. Each test runs independently, so all failures are reported. Options A and B combine checks in one test, so the first failure stops the test. Option D has a wrong assertion for response time.