Test Overview
This test sends a GET request to a sample API endpoint and verifies that the response status code is 200 and the response body contains the expected data.
This test sends a GET request to a sample API endpoint and verifies that the response status code is 200 and the response body contains the expected data.
pm.test("Status code is 200", function () { pm.response.to.have.status(200); }); pm.test("Response has expected user data", function () { const jsonData = pm.response.json(); pm.expect(jsonData).to.have.property('user'); pm.expect(jsonData.user).to.have.property('id').that.is.a('number'); pm.expect(jsonData.user).to.have.property('name').that.is.a('string'); });
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Test starts and sends GET request to https://api.example.com/user/1 | Postman sends HTTP GET request to the API endpoint | - | PASS |
| 2 | Receives HTTP response from the server | Response status code is 200, response body contains JSON with user data | Check that response status code is 200 | PASS |
| 3 | Parse JSON response body | JSON object with user property is available | Verify response JSON has 'user' property with 'id' as number and 'name' as string | PASS |