Test Overview
This test checks if the API response status is 200 and if the response body contains a specific key. It uses pm.test() in Postman's Tests tab to verify these conditions.
This test checks if the API response status is 200 and if the response body contains a specific key. It uses pm.test() in Postman's Tests tab to verify these conditions.
pm.test("Status code is 200", function () { pm.response.to.have.status(200); }); pm.test("Response has userId", function () { var jsonData = pm.response.json(); pm.expect(jsonData).to.have.property('userId'); });
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Test starts in Postman Tests tab | Postman is ready to run the test scripts after receiving the API response | - | PASS |
| 2 | pm.test("Status code is 200") runs and checks response status | API response received with HTTP status code 200 | Verify response status code equals 200 | PASS |
| 3 | pm.test("Response has userId") runs and checks response body | Response body parsed as JSON, contains key 'userId' | Verify response JSON has property 'userId' | PASS |