Testing Overview
RitoSwap’s dapp has a substantial automated test suite (over 200 Vitest files and well over a thousand individual tests) covering wallet UX, token gating, API routes, OpenAPI contracts, and state management.
This page explains how the tests are structured, what each layer is responsible for, and how they work together. It is intentionally focused on project-specific patterns, not generic Vitest tutorials.
This overview focuses on Vitest-based tests inside the dapp.
E2E flows using Playwright, Synpress, Postman, and Supertest are mentioned for context but documented separately.
At a glance
At a glance
- Test runner: Vitest (
vitest,@vitest/ui) with ahappy-domenvironment. - UI testing: React Testing Library +
@testing-library/jest-domfor wallet UX and components. - Network & infra:
- MSW (
msw/node) for mocking external HTTP calls (e.g. Alchemy). - Prisma client mocked globally so tests never touch a real database.
- Next.js primitives (
next/link,next/image,next/navigation) stubbed for DOM-safe rendering.
- MSW (
- API routes: Next.js route handlers (
app/api/.../route.ts) tested directly viaNextRequest+ mocked dependencies. The same pattern is used for every gate‑adjacent surface (gate-access,token-status,nonce,form-submission-gate,quota-reset,chat,mcp, andopenapi). - Contract tests: A dedicated layer (
app/api/__contract__/contract.test.ts) validating example responses againstpublic/openapi.jsonusing an OpenAPI validator. - Coverage: Enforced via
vitest.config.tswith thresholds on branches, functions, lines, and statements, plus a curated exclusion list for infra, configs, and non-critical UI.
The goal is to prioritize security‑critical flows (auth, token gating, rate limiting) and user‑visible wallet UX, rather than chase artificial 100% coverage.
Where to go next
Use the pages below for deeper, layer-specific guidance:
Unit & Component Testing API Route Testing API Contract & OpenAPI Testing