Test Overview
This test sends a GET request with query parameters to an API endpoint and verifies that the response contains the expected filtered data based on those parameters.
This test sends a GET request with query parameters to an API endpoint and verifies that the response contains the expected filtered data based on those parameters.
pm.test("Verify response contains correct query parameter data", function () { const url = pm.request.url; pm.expect(url.getQueryString()).to.include("status=active"); pm.response.to.have.status(200); const jsonData = pm.response.json(); pm.expect(jsonData).to.be.an('array'); jsonData.forEach(item => { pm.expect(item.status).to.eql('active'); }); });
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Test starts and prepares GET request with query parameter 'status=active' | Postman UI shows request URL with '?status=active' appended | - | PASS |
| 2 | Sends GET request to API endpoint with query parameter | Request sent to server with URL including '?status=active' | - | PASS |
| 3 | Receives response with HTTP status 200 and JSON body | Response body contains array of objects with 'status' fields | pm.response.to.have.status(200) | PASS |
| 4 | Checks that request URL contains query parameter 'status=active' | URL query string is 'status=active' | pm.expect(url.getQueryString()).to.include("status=active") | PASS |
| 5 | Verifies each item in response array has 'status' equal to 'active' | All items in JSON array have 'status' field with value 'active' | pm.expect(item.status).to.eql('active') for each item | PASS |