Codecov Test Coverage Integration
Coverage configuration for Sanctiv - optimized for startup stage.Philosophy
Test business logic, not UI. Maestro E2E covers user journeys.| What We Test | How | Coverage Target |
|---|---|---|
| Pure functions (utils) | Jest unit tests | 80%+ enforced |
| Data mappers | Jest unit tests | 80%+ enforced |
| User journeys | Maestro E2E | N/A (not tracked) |
| UI components | Maestro E2E | Not unit tested |
- ✅ Path-specific thresholds on critical code
- ✅ Global threshold = 0 (don’t block PRs for UI code)
- ✅ Codecov tracks trends without blocking merges
- ✅ Component-based coverage tracking
Quick Start
Run Tests Locally
View Coverage Report
After runningtest:coverage, open coverage/lcov-report/index.html in a browser for detailed line-by-line coverage visualization.
Configuration
jest.config.js - Path-Specific Thresholds
codecov.yml - Trend Tracking
What’s Ignored (Not Tracked)
- UI components (
src/components/**,src/screens/**) - Design system (
src/design-system/components/**) - Flow engine components (
src/flow-engine/components/**) - Type definitions, generated files, configs
What to Test
Currently Tested (100% coverage)
| File | Tests |
|---|---|
src/utils/cn.ts | 5 tests |
src/utils/pickerUtils.ts | 13 tests |
src/services/supabase/journal.mappers.ts | 15 tests |
Next Priority (when needed)
| File | Why |
|---|---|
src/services/supabase/library.mappers.ts | Data integrity |
src/state/authStore.ts | Auth logic critical |
src/state/journalStore.ts | Core feature |
Skip (Covered by Maestro E2E)
src/components/**- UI renderingsrc/screens/**- Full user flowssrc/design-system/**- Visual components
Writing Tests
Test File Structure
Create tests in__tests__ directories:
Example: Testing Pure Functions
Example: Testing Data Mappers
Example: Testing Zustand Stores
Troubleshooting
Coverage Threshold Failures
Issue:Jest: "global" coverage threshold not met
Solution: Thresholds are progressive. Current phase allows low coverage:
Codecov Upload Fails
Issue: Upload step fails in GitHub Actions Checklist:- ✅
CODECOV_TOKENset in GitHub Secrets - ✅ Token matches Codecov dashboard
- ✅
coverage/lcov.infofile generated - ✅ Workflow has correct permissions
React Native Module Errors
Issue:Cannot find module 'react-native/...'
Solution: Handled by transformIgnorePatterns in jest.config.js. If issues persist:
Best Practices
1. Test Behavior, Not Implementation
2. One Assertion Per Test
3. Use Descriptive Names
4. Arrange-Act-Assert Pattern
Codecov Dashboard
Viewing Coverage
- Go to codecov.io
- Sign in with GitHub
- Select
Sanctiv/sanctiv-app - View:
- Coverage % - Overall project coverage
- Components - Per-area coverage breakdown
- Files - Line-by-line coverage
- Commits - Coverage trends over time
PR Comments
Codecov automatically comments on PRs showing:- Overall coverage change (+/- from base)
- Patch coverage (new code only)
- Uncovered lines in diff
- Component breakdown
Related Documentation
- TESTING.md - E2E testing with Maestro
- codecov.yml - Full Codecov configuration (must be at repository root per Codecov requirements)
- jest.config.js - Jest configuration for mobile app