| name | run-tests |
| description | Use when the user asks to run tests, ejecutar tests, lanzar tests, pytest, vitest, check types, typecheck, lint, or verify the codebase. Runs backend pytest, frontend vitest, frontend tsc/eslint/prettier, and backend ruff/black. |
Run Tests — FreeLingo
Backend tests (pytest)
The project does NOT use Docker for local tests. Tests are fully isolated:
- SQLite in-memory (no PostgreSQL needed)
- Redis mocked in-memory (no Redis server needed)
- LLM always mocked (no external API calls)
Prerequisites
python3 -m venv .venv && source .venv/bin/activate && pip install -r backend/requirements.txt
.venv/ is already in .gitignore. Create it once, activate before each session.
Run
source .venv/bin/activate && cd backend && pytest -v
Use a command timeout of at least 600 seconds for the full backend suite; the current run takes about 4 minutes and can exceed shorter 120-second tool defaults.
Options:
- Single file:
source .venv/bin/activate && cd backend && pytest tests/test_auth.py -v
- Single test:
source .venv/bin/activate && cd backend && pytest tests/test_flashcards.py::test_quality_3_basic_progression -v
- Coverage HTML:
source .venv/bin/activate && cd backend && pytest --cov-report=html
Frontend tests (vitest)
cd frontend && npm run test:run
419 tests covering stores, components, hooks, app pages, lib, i18n, middleware, review UI, review prompt triggers, billing UI, and API interceptor. Frontend coverage is not configured/reported:
lib/api.ts — auth interceptor, 401 refresh, retry
store/auth.ts — isSubscribed(), logout
lib/audio.ts — float32ToWav WAV encoding
lib/conversation-ws.ts — WebSocket URL builder
middleware.ts — route protection, locale detection
store/config.ts — config loading, idempotency
store/language.ts — language CRUD, switching
store/progress.ts — XP, streak, unit progress, level test
lib/mappers.ts — mapUser transformation
lib/target-languages.ts — language code resolution
data/curriculum.ts — curriculum data integrity
components/LanguageSwitcher.tsx — sidebar dropdown
components/TargetLanguageSelector.tsx — language grid
components/VoiceRecorder.tsx — STT recorder states
components/AudioPlayer.tsx — TTS player states
components/ProfileSection.tsx — profile CRUD, avatar
components/UnitCard.tsx + UnitDrawer.tsx — plan units
components/reviews/* — review prompt and landing carousel
app/(app)/admin/reviews/page.tsx — review moderation UI
lib/reviews.ts — review API client
lib/review-prompt-triggers.ts — voice-session and unit-completion review prompt triggers
Options:
- Watch mode:
npm run test
- Single file:
npx vitest run tests/lib/api.test.ts
Frontend checks
cd frontend && npx tsc --noEmit
cd frontend && npm run lint
cd frontend && npx prettier --check src/
Backend lint
source .venv/bin/activate && cd backend && ruff check . && black --check .
If a suite fails
- If any backend or frontend test fails after launching a suite, STOP immediately, report the failing test(s), and ask the user how to proceed.
- Do not modify production code or tests to make the suite pass without explicit user approval.
- If lint, typecheck, or format checks fail without test failures, report the error and ask before making non-formatting code changes.
- After the user approves a fix, re-run only the failing command unless they request the full suite.
Canonical format script
./scripts/format.sh
Runs the same backend/frontend style tools from fixed project paths, so results do not depend on the current working directory.