OOOC Fête Finder uses Vitest as its testing framework. Tests are organized into unit and integration categories with focused coverage on critical business logic.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/KingPsychopath/oooc-fete-finder/llms.txt
Use this file to discover all available pages before exploring further.
Quick Start
Test Organization
All tests live in the__tests__/ directory at the project root:
Unit Tests
Test individual functions and modules in isolation:- Rate limiting logic
- Event key generation
- CSV parsing
- Date normalization
- Calendar utilities
- Logger deduplication
- Feature flag logic
- Fast execution
- No external dependencies
- Mock all I/O (database, network, filesystem)
- Focus on pure logic and transformations
Integration Tests
Test components with real or near-real dependencies:- Runtime service data flow
- Data manager source chain
- API route handlers
- Admin actions
- Event store backup service
- Featured event scheduling
- May use in-memory database mocks
- Test cross-module interactions
- Validate complete workflows
- Verify error handling and edge cases
Configuration
Vitest configuration is invitest.config.ts:
vitest.config.ts
Key Settings
Environment:nodeTests run in Node.js environment (not browser/jsdom). Globals:
trueVitest globals like
describe, it, expect are available without imports.
Setup files: test/setup-env.tsRuns before all tests to set default environment variables:
test/setup-env.ts
@Resolves to project root, matching Next.js configuration. Mock
server-onlyReplaces Next.js
server-only module for testing.
Coverage
Coverage focuses on critical business logic:Covered modules
Covered modules
Data management
features/data-management/**/*.ts- CSV processing
- Event validation
- Source chain (Postgres → CSV fallback)
- Coordinate warmup
lib/platform/postgres/**/*.ts- KV store repository
- Event store repository
- Rate limit repository
- Engagement tracking
features/auth/**/*.ts- Token generation
- Session management
- Verification flow
- Text: Terminal summary (lines, statements, branches, functions)
- HTML: Browse detailed coverage at
coverage/index.html
HTML reports include line-by-line coverage visualization. Open
coverage/index.html in a browser after running pnpm test:coverage.Writing Tests
Unit Test Pattern
Here’s a typical unit test structure using mocking:__tests__/unit/rate-limiter.test.ts
- Module reset:
vi.resetModules()ensures clean state - Mock dependencies:
vi.doMock()replaces imports - Type-safe mocks: Define mock types for autocomplete
- Dynamic imports:
await import()after mocking - Clear mocks:
vi.clearAllMocks()inbeforeEach
Integration Test Pattern
Integration tests mock fewer dependencies:__tests__/integration/runtime-service.test.ts
- Mock only external boundaries (database, API clients)
- Allow real interactions between internal modules
- Test complete user-facing flows
- Verify error propagation
Test Utilities
Mock Factories
Create reusable mock data generators:Async Assertions
Vitest supports async matchers:Snapshot Testing
Continuous Integration
In CI environments, tests run automatically:- Set
CI=trueenvironment variable - Run coverage checks
- Fail on any test failures
- Cache
node_modules/for faster runs
Common Patterns
Testing Error Handling
Testing Feature Flags
Testing Time-Dependent Logic
Debugging Tests
Run specific test file
Run specific test case
Enable verbose output
Debug in VS Code
Add to.vscode/launch.json:
Best Practices
Testing guidelines
Testing guidelines
1. Test behavior, not implementationFocus on what the code does, not how it does it.2. Use descriptive test names3. One assertion per test (when possible)Makes failures easier to diagnose.4. Avoid test interdependenceEach test should run independently. Use
beforeEach for setup.5. Mock at boundariesMock external services (database, API), but let internal modules interact naturally.6. Test error pathsDon’t just test happy paths. Verify error handling and edge cases.7. Keep tests fastUnit tests should run in milliseconds. If slow, consider mocking more aggressively.