Skip to Content
Welcome to RitoSwap's documentation!
dAppVitestOverview

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

  • Test runner: Vitest (vitest, @vitest/ui) with a happy-dom environment.
  • UI testing: React Testing Library + @testing-library/jest-dom for 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.
  • API routes: Next.js route handlers (app/api/.../route.ts) tested directly via NextRequest + mocked dependencies. The same pattern is used for every gate‑adjacent surface (gate-access, token-status, nonce, form-submission-gate, quota-reset, chat, mcp, and openapi).
  • Contract tests: A dedicated layer (app/api/__contract__/contract.test.ts) validating example responses against public/openapi.json using an OpenAPI validator.
  • Coverage: Enforced via vitest.config.ts with 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

RitoSwap Docs does not store, collect or access any of your conversations. All saved prompts are stored locally in your browser only.