Root Makefile with timeout-protected test targets: - Tier 1 (<30s): make test, make test-unit, make test-frontend - Tier 2 (smart): make test-related F=file.py (via @RELATION BINDS_TO) - Tier 3 (<5min): make test-integration (Docker, --run-integration) - Coverage: make coverage (backend + frontend) - Lint: make lint (ruff + eslint) Smart test selector (scripts/find-related-tests.py): - Extracts module names from #region anchors, class/function defs - Searches 400 BINDS_TO entries across all test files - Confidence scoring: exact > case-insensitive > substring > heuristic - Fallback: filename-based fuzzy matching OpenCode commands: - /test.all — full suite + coverage - /test.unit — fast unit tests (<30s) - /test.related — smart selection by file - /test.coverage — coverage reports with thresholds Speckit workflow updated: - speckit.test.md: raw pytest → make targets with timeout safety - speckit.plan.md: quickstart uses make targets - speckit.tasks.md: verification uses make targets - speckit.implement.md: default stack uses make targets Frontend: added 'coverage' script to package.json
2.5 KiB
2.5 KiB
description, handoffs, tools
| description | handoffs | tools | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| Generate coverage reports for both backend and frontend, and verify against thresholds. |
|
bash, read, grep |
User Input
$ARGUMENTS
Goal
Generate test coverage reports for backend (pytest-cov) and frontend (vitest v8), and verify that coverage meets project thresholds.
Required Skills
MANDATORY USE skill({name="semantics-testing"}) — coverage conventions.
Execution Steps
1. Generate coverage reports
make coverage
2. Review backend coverage
# Detailed terminal output with uncovered lines
cd backend && source .venv/bin/activate && python -m pytest tests/ --ignore=tests/integration/ --cov=src --cov-report=term-missing 2>&1 | tail -50
Key metrics to extract:
- Overall statement coverage (%)
- Files with <80% coverage (list top 5 offenders)
- Files with 0% coverage (untested)
3. Review frontend coverage
# Frontend coverage (also available via make coverage-frontend)
cd frontend && npx vitest run --coverage 2>&1 | tail -50
Frontend thresholds in vitest.config.js:
- Statements: 98%
- Lines: 98%
- Functions: 95%
- Branches: 80%
4. Check against thresholds
If any threshold is not met, identify the specific files/modules dragging coverage down.
5. (Optional) Open HTML reports
ls backend/htmlcov/index.html && echo "Backend report: backend/htmlcov/index.html"
ls frontend/coverage/index.html && echo "Frontend report: frontend/coverage/index.html"
Output Format
## Coverage Report
### Backend (pytest-cov)
- Statement Coverage: XX%
- Files below 80%: N (list top 3-5)
- Untested files: N (list top 3-5)
### Frontend (vitest v8)
- Statement Coverage: XX% (threshold: 98%) [PASS/FAIL]
- Line Coverage: XX% (threshold: 98%) [PASS/FAIL]
- Function Coverage: XX% (threshold: 95%) [PASS/FAIL]
- Branch Coverage: XX% (threshold: 80%) [PASS/FAIL]
### HTML Reports
- Backend: backend/htmlcov/index.html
- Frontend: frontend/coverage/index.html
### Overall: [ALL_THRESHOLDS_MET / BELOW_THRESHOLD]
Constraints
- Coverage is generated from unit tests ONLY (no Docker integration tests).
- If vitest coverage fails with "threshold not met", report which files are below threshold.
- Do NOT modify source code to artificially increase coverage.