Test Overview
This test sends a GET request to a sample API endpoint and verifies that the JSON response contains specific values. It checks that the user ID is 1 and the username is 'Bret'.
This test sends a GET request to a sample API endpoint and verifies that the JSON response contains specific values. It checks that the user ID is 1 and the username is 'Bret'.
pm.test("Verify JSON response values", () => { const jsonData = pm.response.json(); pm.expect(jsonData.id).to.eql(1); pm.expect(jsonData.username).to.eql("Bret"); });
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Send GET request to https://jsonplaceholder.typicode.com/users/1 | Request sent, waiting for response | - | PASS |
| 2 | Receive JSON response with user data | Response body contains JSON with fields including id and username | - | PASS |
| 3 | Parse JSON response to extract fields | jsonData object created with response values | - | PASS |
| 4 | Assert that jsonData.id equals 1 | jsonData.id is 1 | pm.expect(jsonData.id).to.eql(1) | PASS |
| 5 | Assert that jsonData.username equals 'Bret' | jsonData.username is 'Bret' | pm.expect(jsonData.username).to.eql("Bret") | PASS |