Testing Philosophy
VoiceTypr uses a comprehensive testing approach:- Frontend: User-focused integration tests (Vitest + React Testing Library)
- Backend: Unit tests for business logic (Cargo test)
- Quality gates: Automated checks before commits
Key Principles
- Test behavior, not implementation - Focus on what users see and do
- Integration over unit - Test complete user journeys
- Edge cases matter - Test error conditions and boundary cases
- Fast feedback - Tests run in seconds, not minutes
Frontend Tests (Vitest)
Run Tests
Test Files
Example Test
Test Configuration
vite.config.ts:
Backend Tests (Cargo)
Run Tests
Test Files
Example Test
Test Dependencies
Cargo.toml:
Quality Gate Checks
Run All Checks
- Type checking (
pnpm typecheck) - Linting (
pnpm lint) - Frontend tests (
pnpm test run) - Backend tests (
pnpm test:backend)
Individual Checks
Quality Gate Script
scripts/quality-gate-check.sh:
Coverage
Frontend Coverage
- Terminal summary
- HTML report in
coverage/
- Statements: >80%
- Branches: >75%
- Functions: >80%
- Lines: >80%
Backend Coverage
Testing Patterns
Frontend Testing
User-Focused Tests
Async Operations
Backend Testing
Async Tests
Mocking
Serial Tests
Continuous Integration
Tests run automatically on:- Pull requests - All quality checks
- Commits to main - Full test suite
- Release builds - Quality gate + E2E tests
GitHub Actions
Benchmarking
Performance benchmarks for critical paths:- Audio recording latency
- Transcription speed (by model size)
- Model loading time
- Memory usage
Troubleshooting
Tests Timeout
Increase timeout in Vitest:Backend Tests Fail to Compile
Ensure dev dependencies are installed:Mock Tauri API in Tests
Use@tauri-apps/api-mock:
Next Steps
- Follow code style when writing tests
- Review contributing guide for PR requirements
- Check architecture for testable patterns