REST API
GET All Users
RequestValidateFilterEasy
What you will learn
- Assert on both status code AND response shape — a 200 with wrong body is still a bug
- Validate pagination metadata (total, page, perPage) before trusting the array length
- Separate schema validation (structure) from business validation (values) in your tests
Description
Retrieve a list of all users with pagination support. Verify response structure and status code.
Test Scenario
const response = await request.get('/api/v1/users');
expect(response.status()).toBe(200);
// The API wraps results in an envelope: { success, data: [...], meta: { total } }
const body = await response.json();
expect(Array.isArray(body.data)).toBe(true);
expect(body.meta.total).toBeGreaterThan(0);Endpoint
/api/v1/usersTesting Tips
- •Check status code is 200
- •Verify response.data is an array (results come wrapped in an envelope)
- •Test pagination with ?page and ?limit
// Playwright - GET all usersimport { test, expect } from '@playwright/test';test('GET /api/v1/users', async ({ request }) => {const response = await request.get('/api/v1/users');expect(response.ok()).toBeTruthy();expect(response.status()).toBe(200);// The API wraps results in an envelope: { success, data: [...], meta: { total } }const body = await response.json();expect(Array.isArray(body.data)).toBe(true);expect(body.data.length).toBeGreaterThan(0);// Verify user structure (users live under .data)const user = body.data[0];expect(user).toHaveProperty('id');expect(user).toHaveProperty('name');expect(user).toHaveProperty('email');});
Challenge ID: rest-get-users
2 frameworks available
API Playground
Send requests and inspect responses
Endpoint: /api/v1/users
Press Enter to send