Testing Overview
Obsidian Chess Studio maintains comprehensive test coverage across both frontend (React/TypeScript) and backend (Rust) to ensure reliability and prevent regressions.Test Statistics
Frontend Tests
- 173 test files
- 307 passing tests
- Vitest with v8 coverage
- ~22% coverage (growing)
Backend Tests
- 234 passing tests
- Cargo test framework
- Comprehensive coverage
- 3.44s execution time
Running Tests
Frontend Tests
- Quick Run
- Watch Mode
- Coverage Report
- Specific Tests
Backend Tests
- All Tests
- Specific Module
- With Output
- Ignored Tests
Frontend Test Coverage
Current frontend coverage metrics:| Metric | Coverage | Target |
|---|---|---|
| Statements | 21.06% | 60%+ |
| Branches | 15.88% | 50%+ |
| Functions | 17.97% | 60%+ |
| Lines | 22.03% | 60%+ |
Well-Tested Areas
Profile Components (92.59%)
Profile Components (92.59%)
Excellent coverage for profile-related components:
PersonalCard.tsx- Player profile cardsProfileAccountSelector.tsx- Account selectionProfilePanel.tsx- Profile managementProfileSelector.tsx- Profile switching
Chess Utilities (96.63%)
Chess Utilities (96.63%)
Comprehensive coverage for chess engine utilities:
- Engine configuration
- UCI command parsing
- Engine path resolution
- Process management
src/utils/engines/__tests__/Utility Functions (87.5%)
Utility Functions (87.5%)
High coverage for helper utilities:
- i18n configuration
- Formatters (dates, chess notation, scores)
- Environment detection
- Chess position utilities
src/utils/__tests__/Areas Needing Coverage
Backend Test Coverage
Well-Tested Modules
- Database Operations
- Position Search
- PGN Processing
- Pawn Structures
- Puzzle System
Comprehensive coverage for:Location:
- Player statistics queries
- Game filtering and search
- Position caching
- Bulk insert operations
- Online sync state
src-tauri/src/db/*/testsWriting Frontend Tests
Test Structure
Frontend tests use Vitest with React Testing Library.Testing Patterns
- Component Testing
- Mocking Tauri Commands
- Testing Hooks
- Testing State
Writing Backend Tests
Test Structure
Rust tests are typically in the same file as the code:Testing Patterns
- Unit Tests
- Database Tests
- Error Handling
- Async Tests
Test Helpers
Continuous Integration
GitHub Actions
Tests run automatically on:- Every commit to any branch
- Pull requests before merge
- Pre-release builds
.github/workflows/test.yml
Coverage Goals
Our goal is to increase coverage to:
- Frontend: 60%+ statement coverage
- Backend: Maintain 90%+ coverage
Viewing Coverage
- Terminal
- HTML Report
Best Practices
Write Tests First
Consider TDD (Test-Driven Development):
- Write failing test
- Implement feature
- Test passes
Test Edge Cases
Don’t just test happy paths:
- Empty inputs
- Invalid data
- Boundary conditions
- Error cases
Keep Tests Simple
- One assertion per test (when possible)
- Clear test names
- Minimal setup
- No complex logic in tests
Mock External Dependencies
- Mock Tauri commands
- Mock external APIs
- Use in-memory databases
- Avoid network calls
Next Steps
Contributing
Submit your code with tests
Architecture
Understand what to test
