APIRequestContext · Synthetic data

Playwright API testing practice

Exercise request lifecycles, negative responses, authentication, and API-assisted UI workflows against a versioned sandbox that is isolated from WordPress and from other learners.

Owned test data

Build one complete request lifecycle

A useful API test owns its setup and cleanup, asserts more than a 200 response, and makes cookie sharing with the browser explicit.

Create isolated state

POST a synthetic customer, product, order, task, ticket, booking, employee, or user in your current Lab session.

Assert the contract

Check status, headers, identifiers, types, error shape, and the business value that should change.

Connect API and UI

Use API setup to reach the user journey faster, then verify the visible behavior without hiding the action under test.

Reset deliberately

POST to the caller-only reset route and prove another browser context keeps its independent data.

Stable practice surface

Choose the right request context

Use Playwright’s isolated request fixture when the API test must own its own cookies. Use page.request only when the API call is meant to share the browser context’s session. Whichever path you choose, assert the expected identity boundary.

  • /practice/api/v1/users for basic CRUD and validation
  • /practice/api/v1/auth/token for synthetic bearer flows
  • /practice/api/v1/store/* for API-to-UI ecommerce work
  • /practice/api/v1/lab/reset for caller-only cleanup