This document covers all test layers in the Agora frontend — unit tests, end-to-end tests, and visual regression tests.
- Unit & Integration Tests (Vitest)
- End-to-End Tests (Cypress)
- Visual Regression Tests (Playwright)
- CI Pipeline
Tests live in apps/web/__tests__/.
# Run all unit tests once
pnpm --filter web test
# Run with coverage
pnpm --filter web test:ciCoverage threshold: 80 % on all included component files.
Cypress specs live in cypress/integration/ at the repo root.
# Start the app first (separate terminal)
pnpm --filter web dev
# Run all Cypress specs headlessly
pnpm cy:run
# Open the interactive Cypress runner
pnpm cy:openAll backend API calls are stubbed with cy.intercept() — no live database required.
Visual snapshot tests guard the Neubrutalist design system (hard borders, specific drop-shadow offsets, accent colour tokens) against accidental CSS regressions.
Four core components are tested in both light and dark mode, producing 8 base snapshots:
| Component | Light snapshot | Dark snapshot |
|---|---|---|
Button |
button-light.png |
button-dark.png |
EventCard |
event-card-light.png |
event-card-dark.png |
RegistrationBox |
registration-box-light.png |
registration-box-dark.png |
TicketModal (purchase) |
ticket-modal-purchase-light.png |
ticket-modal-purchase-dark.png |
TicketModal (waitlist) |
ticket-modal-waitlist-light.png |
ticket-modal-waitlist-dark.png |
Snapshots are committed to tests/visual/__snapshots__/ and diff-visible in pull request reviews.
Playwright and its browsers are listed as dev dependencies. Install them once:
# From the repo root
pnpm install
# Install Playwright browser binaries (Chromium only, as configured)
pnpm --filter web exec playwright install chromium# From apps/web — starts the Next.js dev server automatically
npx playwright test
# Or via the pnpm script shortcut
pnpm --filter web test:visualRun this command any time you make an intentional design change and want to accept the new visuals as the new baseline:
npx playwright test --update-snapshotsImportant: Always commit the updated snapshots in the same PR as the design change so reviewers can diff the images directly in GitHub.
After a test run, open the HTML report to inspect screenshot diffs:
npx playwright show-reportA test fails when:
- Pixel diff > 0.2% between the new screenshot and the stored base snapshot.
- A CSS design token (e.g.
--color-accent,border-black, shadow offset) changes and affects a component in the fixture page. - The component is not visible (network/auth error in the fixture page).
The Neubrutalist design tokens – runtime assertion test group will also fail immediately — before any screenshot comparison — if:
- The
Buttonloses its hard0pxblur drop-shadow. - The
EventCardloses itsrgba(0,0,0)shadow colour.
The fixture page (/apps/web/app/__visual_fixtures__/page.tsx) renders all four components in isolation using static props — no authentication, no API calls, no routing dependencies. It is never linked from the public app and is excluded from the sitemap.
The GitHub Actions workflow (.github/workflows/frontend.yml) runs:
- Build & Lint —
pnpm --filter web build+ ESLint - Cypress E2E — headless Cypress against the dev server
- Playwright Visual — snapshot comparison (added in issue #1106)
The Playwright job uploads the HTML report and any failed screenshot diffs as CI artifacts on failure.