Testing Strategy for Ariane Monorepo
Testing Strategy for Ariane Monorepo
Section titled “Testing Strategy for Ariane Monorepo”Current State
Section titled “Current State”- ✅ Basic security autofix testing (
scripts/test-security-autofix.js
) - ✅ Lighthouse configuration (
.lighthouserc.js
) - ✅ ESLint + Prettier for code quality
- ❌ No unit/integration tests for components
- ❌ No API route testing
- ❌ No authentication flow testing
- ❌ No E2E testing
Recommended Testing Stack
Section titled “Recommended Testing Stack”1. Vitest - Unit & Integration Testing
Section titled “1. Vitest - Unit & Integration Testing”Why: Fast, modern, works great with TypeScript and Astro Coverage: Components, utilities, API routes, middleware
2. Playwright - E2E Testing
Section titled “2. Playwright - E2E Testing”Why: Excellent for testing full authentication flows, cross-browser Coverage: User journeys, WebAuthn, Cloudflare Access integration
3. MSW (Mock Service Worker) - API Mocking
Section titled “3. MSW (Mock Service Worker) - API Mocking”Why: Reliable API mocking for tests and development Coverage: External APIs (Sanity, Zitadel, GitHub OAuth)
4. Testing Library - Component Testing
Section titled “4. Testing Library - Component Testing”Why: Best practices for testing user interactions Coverage: Astro components, React components (Studio)
Implementation Plan
Section titled “Implementation Plan”Phase 1: Foundation Setup
Section titled “Phase 1: Foundation Setup”- Add Vitest configuration
- Create test utilities and helpers
- Set up MSW for API mocking
- Add basic component tests
Phase 2: API & Integration Testing
Section titled “Phase 2: API & Integration Testing”- Test API routes (
/api/auth/*
,/api/oauth/*
) - Test middleware authentication logic
- Test Sanity CMS integration
- Test WASM fallback mechanisms
Phase 3: End-to-End Testing
Section titled “Phase 3: End-to-End Testing”- Set up Playwright
- Test complete authentication flows
- Test WebAuthn registration/authentication
- Test Cloudflare Access integration
Phase 4: Performance & Security Testing
Section titled “Phase 4: Performance & Security Testing”- Lighthouse CI integration
- Security vulnerability testing
- Performance regression testing
- Bundle size monitoring
Quick Start Commands
Section titled “Quick Start Commands”# Run all testsnpm run test
# Run tests with coveragenpm run test:coverage
# Run E2E testsnpm run test:e2e
# Run performance testsnpm run test:performance
# Run security testsnpm run test:security
File Structure
Section titled “File Structure”tests/├── unit/ # Unit tests│ ├── lib/ # Library utilities│ ├── components/ # Component tests│ └── middleware/ # Middleware tests├── integration/ # Integration tests│ ├── api/ # API route tests│ ├── auth/ # Authentication tests│ └── sanity/ # CMS integration tests├── e2e/ # End-to-end tests│ ├── auth-flow.spec.ts│ ├── webauthn.spec.ts│ └── studio.spec.ts├── fixtures/ # Test data and fixtures├── helpers/ # Test utilities└── setup/ # Test environment setup