Playwright API testing practice project. The suite uses a setup project to authenticate via the Conduit API, persists the token to storageState, injects it into requests via Authorization headers, intercepts the api/tags call with mocked data from test-data/tags.json, and exercises UI + API workflows in the Conduit app.
Tech
- Playwright Test
- TypeScript
Project Structure
tests/workingWithAPI.spec.ts- UI + API tests (route mocking, article CRUD)test-data/tags.json- mocked tags payload.auth/auth.setup.ts- API login and storage state generation.auth/user.json- saved storage state (jwt token)playwright.config.ts- Playwright configuration
Setup
- Install dependencies:
npm install
- Test auth is handled by Playwright's
setupproject. It logs in via the API and writes the jwt to.auth/user.json.
Run Tests
- Run the suite:
npm run test:api
Notes
- The
setupproject logs in via the API, writes.auth/user.json, and setsACCESS_TOKENforextraHTTPHeaders. - The suite mocks
*/**/api/tagsand uses the stored auth state. - Tests include:
- Mocking the articles feed and asserting the UI renders the mocked title/description.
- Creating an article via API, deleting it via UI, and validating it is removed.
- Creating an article via UI, capturing the slug from the network response, and deleting it via API.