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 a specific key with the expected value.
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 a specific key with the expected value.
pm.test("Status code is 200", function () { pm.response.to.have.status(200); }); pm.test("Response has userId 1", function () { var jsonData = pm.response.json(); pm.expect(jsonData.userId).to.eql(1); });
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Send GET request to https://jsonplaceholder.typicode.com/posts/1 | Request sent, waiting for response | - | PASS |
| 2 | Receive response with status code 200 and JSON body | Response received: {"userId":1,"id":1,"title":"...","body":"..."} | Check if status code is 200 | PASS |
| 3 | Parse JSON response body | Parsed JSON object available | Verify jsonData.userId equals 1 | PASS |