Pagination is a technique to divide large sets of data into smaller chunks or pages, making it easier to retrieve and display data step-by-step.
Click to reveal answer
beginner
Why do we test pagination in APIs?
We test pagination to ensure that the API correctly returns the right number of items per page, handles page navigation properly, and does not skip or repeat data.
Click to reveal answer
intermediate
In Postman, how can you test the number of items returned per page?
You can write a test script using JavaScript in the Tests tab to check the length of the response array matches the expected page size.
Click to reveal answer
beginner
What is a common parameter used for pagination in APIs?
Common parameters include 'page' (which page number to fetch) and 'limit' or 'pageSize' (how many items per page).
Click to reveal answer
intermediate
How do you verify that pagination does not skip or repeat items?
By requesting multiple pages in sequence and checking that the combined data matches the full dataset without duplicates or missing items.
Click to reveal answer
Which parameter typically controls the page number in API pagination?
Apage
Blimit
Csort
Dfilter
✗ Incorrect
The 'page' parameter specifies which page of data to retrieve.
In Postman, where do you write scripts to test pagination responses?
ATests tab
BPre-request Script tab
CBody tab
DHeaders tab
✗ Incorrect
The Tests tab is used to write JavaScript code to validate responses.
What should you check to ensure pagination is working correctly?
AResponse time only
BOnly the first page data
CNumber of items per page and correct page navigation
DHeaders only
✗ Incorrect
Testing pagination involves checking the number of items per page and that pages navigate correctly.
If an API returns 10 items per page, how many items should you get after requesting pages 1 and 2?
A10
B20
C5
DDepends on the API
✗ Incorrect
Two pages with 10 items each should return 20 items total.
Which test ensures no data is skipped or repeated across pages?
APerformance test
BUI test
CSecurity test
DData integrity test
✗ Incorrect
Data integrity tests verify that pagination returns all data without duplicates or missing items.
Explain how you would test pagination using Postman.
Think about parameters, requests, and validation scripts.
You got /5 concepts.
Why is testing pagination important in API testing?
Consider the impact on data retrieval and display.
You got /4 concepts.
Practice
(1/5)
1. What is the main purpose of testing pagination in an API using Postman?
easy
A. To verify that users can navigate through pages and see correct data counts
B. To check if the API returns data in alphabetical order
C. To ensure the API response time is under 1 second
D. To test if the API supports multiple languages
Solution
Step 1: Understand pagination purpose
Pagination testing ensures users can move through pages and see correct data on each page.
Step 2: Identify key verification points
We check page numbers, item counts, and total items to confirm correct navigation.
Final Answer:
To verify that users can navigate through pages and see correct data counts -> Option A
Quick Check:
Pagination = navigation + correct data [OK]
Hint: Pagination tests check page navigation and item counts [OK]
Common Mistakes:
Confusing pagination with sorting
Focusing only on response time
Ignoring total item count
2. Which Postman script snippet correctly checks if the current page number is 3 in the response JSON?
easy
A. pm.test('Page is 3', () => pm.expect(pm.response.page).to.eql(3));
B. pm.test('Page is 3', () => pm.expect(response.page).to.equal(3));
C. pm.test('Page is 3', () => pm.expect(pm.response.json().page).to.eql(3));
D. pm.test('Page is 3', () => pm.expect(json.page).to.eql(3));
Solution
Step 1: Access response JSON correctly
Use pm.response.json() to parse the response body as JSON.
Step 2: Use correct assertion syntax
pm.expect(...).to.eql(3) checks if the page value equals 3.
Final Answer:
pm.test('Page is 3', () => pm.expect(pm.response.json().page).to.eql(3)); -> Option C
Quick Check:
Use pm.response.json() + pm.expect() [OK]
Hint: Use pm.response.json() to parse JSON before assertions [OK]
Common Mistakes:
Using undefined variables like response or json
Accessing pm.response.page directly
Using to.equal instead of to.eql in Postman
3. Given this Postman test script, what will be the test result if the response JSON is {"page":2,"per_page":5,"total":12,"data":[1,2,3,4,5]}?
The response JSON is {"page":1,"per_page":10,"total":50}. What is the likely error?
medium
A. The assertion syntax is correct; failure is due to response mismatch
B. Using to.equal instead of to.eql causes failure
C. pm.response.json() is not called correctly
D. The response JSON does not contain page key
Solution
Step 1: Check assertion method
to.equal and to.eql behave similarly for primitives; this is not the cause.
Step 2: Verify response JSON keys
Response has page key with value 1, so JSON access is correct.
Step 3: Consider response mismatch
If test fails, likely the actual response page value differs or test runs on wrong response.
Final Answer:
The assertion syntax is correct; failure is due to response mismatch -> Option A
Quick Check:
Assertion syntax correct; check response data [OK]
Hint: Check actual response data if assertion syntax looks correct [OK]
Common Mistakes:
Confusing to.equal and to.eql for primitives
Assuming JSON parsing failed
Ignoring actual response content
5. You want to test that the API correctly handles the last page of pagination when total items are 23 and per_page is 5. Which Postman test script correctly verifies the last page number and item count on that page?