Test Overview
This test sends a request to an API endpoint and checks the response status and body content. It verifies that the API returns the expected data, confirming the correctness of the response.
This test sends a request to an API endpoint and checks the response status and body content. It verifies that the API returns the expected data, confirming the correctness of the response.
pm.test("Status code is 200", function () { pm.response.to.have.status(200); }); pm.test("Response has expected user name", function () { const jsonData = pm.response.json(); pm.expect(jsonData.name).to.eql("John Doe"); });
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Send GET request to API endpoint /users/123 | Postman sends HTTP GET request to the server | - | PASS |
| 2 | Receive HTTP response from server | Response received with status code 200 and JSON body | - | PASS |
| 3 | Check if response status code is 200 | Response status code is 200 OK | pm.response.to.have.status(200) | PASS |
| 4 | Parse response JSON and check if 'name' field equals 'John Doe' | Response JSON contains {"name": "John Doe", ...} | pm.expect(jsonData.name).to.eql("John Doe") | PASS |