Test Overview
This test sends a GET request to an API endpoint and verifies that the response body contains the expected user data, including the user's name and email.
This test sends a GET request to an API endpoint and verifies that the response body contains the expected user data, including the user's name and email.
pm.test("Response body contains correct user data", function () { const responseJson = pm.response.json(); pm.expect(responseJson).to.have.property('name', 'John Doe'); pm.expect(responseJson).to.have.property('email', 'john.doe@example.com'); });
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Test starts | Postman is ready to send the request | - | PASS |
| 2 | Send GET request to API endpoint | Request sent to https://api.example.com/users/123 | - | PASS |
| 3 | Receive response with status 200 and JSON body | Response body: {"id":123,"name":"John Doe","email":"john.doe@example.com"} | Status code is 200 | PASS |
| 4 | Parse response body as JSON | Parsed JSON object available for assertions | - | PASS |
| 5 | Assert response JSON has property 'name' with value 'John Doe' | Checking 'name' property in response JSON | responseJson.name === 'John Doe' | PASS |
| 6 | Assert response JSON has property 'email' with value 'john.doe@example.com' | Checking 'email' property in response JSON | responseJson.email === 'john.doe@example.com' | PASS |
| 7 | Test ends | All assertions passed | - | PASS |