Test Overview
This test sends a GET request to a sample API endpoint and uses the Chai assertion library to verify that the response status is 200 and the response body contains a specific property.
This test sends a GET request to a sample API endpoint and uses the Chai assertion library to verify that the response status is 200 and the response body contains a specific property.
pm.test("Status code is 200", function () { pm.response.to.have.status(200); }); pm.test("Response has userId property", function () { const jsonData = pm.response.json(); pm.expect(jsonData).to.have.property('userId'); });
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Send GET request to https://jsonplaceholder.typicode.com/posts/1 | Request sent, waiting for response | - | PASS |
| 2 | Check response status code using pm.response.to.have.status(200) | Response received with status 200 | Verify status code is 200 | PASS |
| 3 | Parse response JSON and check if it has property 'userId' using pm.expect | Response body parsed as JSON: { userId: 1, id: 1, title: "...", body: "..." } | Verify response JSON has property 'userId' | PASS |