====== Vite + Vitest Testing Strategy for React SPA ====== ===== 1. Context & Goals ===== This document defines **best practices for testing a React SPA built with Vite**. The application is UI-focused, API-driven, and optimized for fast rendering of large datasets (inventory-style screens). ==== Goals ==== Align testing with the Vite build ecosystem Ensure fast, reliable, and deterministic tests Enable **auth token reuse** across Unit, Integration, and E2E tests Support CI/CD quality gates ===== 3. Recommended Testing Stack ===== React + TypeScript + Vite\\ │\\ ├── Unit Tests → Vitest + React Testing Library\\ ├── Integration Tests → Vitest + RTL + MSW\\ ├── API Contract → MSW\\ ├── Hybrid E2E → Playwright + MSW\\ └── Full E2E → Playwright (real backend) ===== 4. Test Classification & Scope ===== ==== Example Code Snippets (Vite + Vitest + React) ==== === 4.0.1 Main App & Layout Wiring === // src/app/App.tsx\\ import { BrowserRouter } from 'react-router-dom';\\ import RoutesConfig from './routes';\\ \\ export default function App() {\\ return (\\ \\ \\ \\ );\\ } // src/layouts/MainLayout/MainLayout.tsx\\ import { Outlet } from 'react-router-dom';\\ import { Header } from '@/components/layout/Header';\\ import { Footer } from '@/components/layout/Footer';\\ import { Menu } from '@/components/layout/Navigation';\\ \\ export const MainLayout = () => (\\ <>\\
\\ \\
\\ \\
\\