End-to-end API automation suite for the Mockerito Education sandbox, covering all CRUD endpoints across 7 resource groups.
| Tool | Purpose |
|---|---|
| @playwright/test | Test runner + APIRequestContext for HTTP |
| Zod | Schema definition and runtime response validation |
| @faker-js/faker | Deterministic random test data generation |
| TypeScript | Static typing throughout all layers |
| Prettier | Consistent code formatting |
| Husky | Git pre-commit hook — runs Prettier via lint-staged |
| lint-staged | Runs Prettier only on staged files |
The project follows a strict layered architecture — each layer has a single responsibility:
dtos/ Zod schemas + inferred TypeScript types (one file per resource)
factories/ Static factory classes — build() / buildMany() / buildUpdate() for test payloads
utils/ Shared utilities (HttpClient with 429 retry, sleep)
services/ One class per endpoint group — wraps HttpClient, returns APIResponse
fixtures/ Playwright fixture files — lifecycle management (create → use → cleanup)
tests/ Spec files — Given / When / Then via test.step()
- DTOs define the shape via Zod; types are always inferred (
z.infer<>) - Services accept
HttpClient(injected) and expose one method per endpoint - HttpClient automatically retries on
429 Too Many Requests(exponential backoff, 3 attempts) - Fixtures compose via
.extend()—enrollment.fixturesextendsstudent.fixturessocreatedStudentis inherited;submission.fixturesextendsenrollment.fixtures - Tests always use
Given / When / Thensteps; the HTTP call is always visible in theWhenstep
| Resource | Tests | Notes |
|---|---|---|
| Auth | 2 | Login success + invalid credentials |
| Assignments | 9 | Full CRUD + types list + submissions sub-resource |
| Courses | 10 | Full CRUD + categories/levels lists + search |
| Teachers | 9 | Full CRUD + specializations list + courses sub-resource |
| Users | 7 | Full CRUD |
| Students | — | Full CRUD service, DTO, factory, and fixture implemented; spec file pending |
| Enrollments | 9 | Full CRUD + statuses list |
| Submissions | 9 | Full CRUD + grade endpoint + statuses list |
Total: 55 tests
npm install
npx playwright install# Full suite
npm test
# Re-run only the last-failed tests (fastest feedback after a fix)
npm run test:failed
# Interactive debug mode — Playwright Inspector opens before each request
npm run test:debug
# Open the HTML report with traces for failed tests
npm run reportThe sandbox enforces a rate limit. Tests run with
--workers=1andHttpClientretries429responses automatically with exponential backoff.
npm run format # fix
npm run format:check # check only (CI)A pre-commit hook (Husky + lint-staged) automatically formats staged .ts, .json, and .md files before every commit.
GitHub Actions runs the full test suite on every push to git branch -M main and every pull request.
Pipeline steps:
- Install dependencies with
npm ci - Run
npm testagainst the live Mockerito sandbox - Upload the Playwright HTML report as a build artifact (retained 30 days)
- Deploy the HTML report to GitHub Pages on every
masterpush
View the latest test report: GitHub Pages report (enable Pages under Settings → Pages → Source → GitHub Actions to activate)
Workflow file: .github/workflows/playwright.yml