Josiah Aubin
← All projects

Playwright API Test Suite

API tests for six JSONPlaceholder resources, built on Playwright Test with typed API clients and Zod schema validation of every response.

  • Playwright
  • TypeScript
  • API Testing
  • Zod
  • GitLab CI

Overview

Playwright isn’t only for browsers. This suite uses Playwright Test’s request API to test the JSONPlaceholder mock REST API, covering its users, posts, comments, albums, photos and todos endpoints.

How it’s structured

  • API clients: each resource gets its own client class that wraps its endpoints, so the tests read as intent (“get user 1”) instead of raw HTTP calls.
  • Zod schemas: every response body is checked against a schema, which catches contract changes such as missing fields or wrong types, not just status codes.
  • Fixtures: shared Playwright fixtures supply the clients to every spec.
  • Configurable target: the suite runs against the live API by default, and setting BASE_URL points the same tests at another environment, such as staging.

CI

Merge request pipelines in GitLab CI run ESLint and the full API suite, with cached dependencies. They publish the HTML report and JUnit results, and also run GitLab’s SAST and secret detection.

JSONPlaceholder doesn’t actually save anything you create or delete, so tests for those operations check the API’s response rather than a change to the data.