Test Overview
This test runs a Postman monitor to check an API endpoint's response status and content. It verifies that the API returns a 200 status code and the expected JSON key.
This test runs a Postman monitor to check an API endpoint's response status and content. It verifies that the API returns a 200 status code and the expected JSON key.
pm.test("Status code is 200", function () { pm.response.to.have.status(200); }); pm.test("Response has userId key", function () { var jsonData = pm.response.json(); pm.expect(jsonData).to.have.property('userId'); });
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Monitor starts and sends HTTP GET request to the API endpoint | Postman Monitor dashboard shows the request is running | - | PASS |
| 2 | Monitor receives HTTP response with status code 200 | Response body contains JSON data with userId and other keys | Check if response status code is 200 | PASS |
| 3 | Monitor runs test to verify response JSON has 'userId' key | Response JSON parsed successfully | Verify presence of 'userId' property in JSON | PASS |
| 4 | Monitor completes execution and reports test results | Postman Monitor dashboard shows tests passed | All tests passed | PASS |