QuorumProof uses automated code coverage reporting to maintain code quality and ensure comprehensive test coverage.
- Tool: Vitest with v8 coverage provider
- Minimum Thresholds: 70% lines, 70% functions, 65% branches, 70% statements
- Reports: HTML, JSON, LCOV, and text formats
- CI/CD: Automated coverage checks on every push and pull request
cd frontend
npm run test:coverageThis will:
- Run all tests with coverage instrumentation
- Generate coverage reports in multiple formats
- Display coverage summary in the terminal
After running coverage, open the HTML report:
open frontend/coverage/lcov-report/index.htmlOr on Linux:
xdg-open frontend/coverage/lcov-report/index.html-
HTML: Interactive coverage report with drill-down capability
- Location:
frontend/coverage/lcov-report/index.html - Best for: Visual inspection and detailed analysis
- Location:
-
JSON: Machine-readable coverage data
- Location:
frontend/coverage/coverage-final.json - Best for: CI/CD integration and programmatic analysis
- Location:
-
LCOV: Standard coverage format
- Location:
frontend/coverage/lcov.info - Best for: Third-party tools like Codecov
- Location:
-
Text: Terminal output summary
- Displayed after test run
- Best for: Quick overview
Current thresholds are configured in frontend/vite.config.ts:
coverage: {
lines: 70,
functions: 70,
branches: 65,
statements: 70,
}To increase coverage requirements:
- Edit
frontend/vite.config.ts - Update the coverage thresholds
- Run
npm run test:coverageto verify - Commit changes
Coverage is automatically reported on:
- Push to main/develop: Full coverage report generated
- Pull Requests: Coverage comment added to PR with metrics
- Artifacts: Coverage reports archived for 30 days
Coverage reports are automatically uploaded to Codecov for:
- Historical tracking
- Badge generation
- Trend analysis
-
Keep functions small and focused
- Easier to test thoroughly
- Better coverage metrics
-
Avoid complex conditionals
- Use helper functions
- Improves branch coverage
-
Test edge cases
- Null/undefined values
- Error conditions
- Boundary values
-
Identify uncovered lines
- Use HTML report to find gaps
- Focus on critical paths first
-
Test error paths
- Mock failures
- Test error handling
-
Test user interactions
- Click handlers
- Form submissions
- Navigation
# Clear cache and reinstall
rm -rf frontend/node_modules frontend/package-lock.json
cd frontend
npm install
npm run test:coverage- Check which files are below threshold
- Add tests for uncovered lines
- Run coverage again to verify improvement
- Check GitHub Actions logs
- Verify Codecov token is set (if using private repo)
- Check file permissions
When submitting pull requests:
- Run
npm run test:coveragelocally - Ensure coverage meets thresholds
- Add tests for new features
- Review coverage report for gaps
Coverage reports are automatically checked in CI/CD and must pass before merging.