Skip to main content

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

  1. Test behavior, not implementation - Focus on what users see and do
  2. Integration over unit - Test complete user journeys
  3. Edge cases matter - Test error conditions and boundary cases
  4. 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

This script runs:
  1. Type checking (pnpm typecheck)
  2. Linting (pnpm lint)
  3. Frontend tests (pnpm test run)
  4. Backend tests (pnpm test:backend)

Individual Checks

Quality Gate Script

scripts/quality-gate-check.sh:

Coverage

Frontend Coverage

Output:
  • Terminal summary
  • HTML report in coverage/
Coverage targets:
  • Statements: >80%
  • Branches: >75%
  • Functions: >80%
  • Lines: >80%

Backend Coverage

Requirements:

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:
Benchmarks:
  • 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