Test Overview
This test sends a GET request to an API endpoint and verifies nested objects in the JSON response. It checks that the user details and address fields exist and have expected values.
This test sends a GET request to an API endpoint and verifies nested objects in the JSON response. It checks that the user details and address fields exist and have expected values.
pm.test("Verify nested user details and address", function () { const jsonData = pm.response.json(); pm.expect(jsonData).to.have.property('user'); pm.expect(jsonData.user).to.have.property('name', 'John Doe'); pm.expect(jsonData.user).to.have.property('address'); pm.expect(jsonData.user.address).to.include({ city: 'New York', zip: '10001' }); });
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Test starts | Postman test runner is ready | - | PASS |
| 2 | Send GET request to API endpoint | API server receives request and sends JSON response with user details | - | PASS |
| 3 | Parse JSON response body | Response body parsed into jsonData object | - | PASS |
| 4 | Check if 'user' property exists in jsonData | jsonData contains 'user' object | jsonData has property 'user' | PASS |
| 5 | Check if 'name' property of user equals 'John Doe' | jsonData.user.name is 'John Doe' | jsonData.user.name === 'John Doe' | PASS |
| 6 | Check if 'address' property exists in user object | jsonData.user.address object exists | jsonData.user has property 'address' | PASS |
| 7 | Check if 'city' and 'zip' in address match expected values | jsonData.user.address.city is 'New York' and zip is '10001' | jsonData.user.address includes {city: 'New York', zip: '10001'} | PASS |
| 8 | Test ends with all assertions passing | All nested object assertions verified successfully | - | PASS |