Test Overview
This test checks if the API pagination works correctly by requesting the first page of results and verifying the response contains the expected number of items and pagination metadata.
This test checks if the API pagination works correctly by requesting the first page of results and verifying the response contains the expected number of items and pagination metadata.
pm.test("Status code is 200", function () { pm.response.to.have.status(200); }); pm.test("Response has pagination info", function () { const jsonData = pm.response.json(); pm.expect(jsonData).to.have.property('page'); pm.expect(jsonData).to.have.property('per_page'); pm.expect(jsonData).to.have.property('total'); pm.expect(jsonData).to.have.property('total_pages'); }); pm.test("Response data length matches per_page", function () { const jsonData = pm.response.json(); pm.expect(jsonData.data.length).to.eql(jsonData.per_page); });
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Send GET request to API endpoint with page=1 parameter | API server receives request and processes pagination parameters | - | PASS |
| 2 | Check response status code is 200 | Response received with status 200 OK | pm.response.to.have.status(200) | PASS |
| 3 | Parse JSON response and verify pagination properties exist | Response JSON contains keys: page, per_page, total, total_pages | pm.expect(jsonData).to.have.property('page') and others | PASS |
| 4 | Verify the length of data array equals per_page value | Data array length matches per_page count | pm.expect(jsonData.data.length).to.eql(jsonData.per_page) | PASS |