Testing pagination helps ensure that data is split correctly across pages. It checks that users can see all items without missing or repeating any.
Testing pagination in Postman
GET /items?page=1&limit=10
Use query parameters like page and limit to control pagination.
Check response fields for total items, current page, and links to next/previous pages.
GET /products?page=2&limit=5
GET /users?page=1&limit=20
This Postman test script checks that the pagination response has the correct current page, the number of items does not exceed the limit, total items is positive, and the next page link is present if there are more pages.
// Postman test script to check pagination // Parse JSON response const response = pm.response.json(); // Check current page is 1 pm.test('Current page is 1', () => { pm.expect(response.page).to.eql(1); }); // Check number of items returned is less or equal to limit pm.test('Items count is correct', () => { pm.expect(response.items.length).to.be.at.most(10); }); // Check total items is a positive number pm.test('Total items is positive', () => { pm.expect(response.total).to.be.above(0); }); // Check next page link exists if more pages pm.test('Next page link exists if not last page', () => { if (response.page * response.limit < response.total) { pm.expect(response.next).to.be.a('string').and.not.empty; } else { pm.expect(response.next).to.be.null; } });
Always check both the data and the pagination metadata in the response.
Test edge cases like the first page, last page, and pages beyond the last.
Use Postman environment variables to automate testing multiple pages.
Pagination testing ensures users can navigate through data pages correctly.
Check page number, item count, total items, and navigation links.
Use Postman scripts to automate and validate pagination behavior.