--- name: run-tests description: Runs backend (pytest) and frontend (Vitest) tests for the duty-teller project. Use when the user asks to run tests, verify changes, or run pytest/vitest. --- # Run tests ## When to use - User asks to "run tests", "run the test suite", or "verify tests pass". - After making code changes and user wants to confirm nothing is broken. - User explicitly asks for backend tests (pytest) or frontend tests (vitest/npm test). ## Backend tests (Python) From the **repository root**: ```bash pytest ``` If imports fail, set `PYTHONPATH`: ```bash PYTHONPATH=. pytest ``` - Config: `pyproject.toml` → `[tool.pytest.ini_options]` (coverage on `duty_teller`, 80% gate, asyncio mode). - Tests live in `tests/`. ## Frontend tests (Next.js / Vitest) From the **repository root**: ```bash cd webapp-next && npm test ``` - Runner: Vitest (`vitest run`); env: jsdom; React Testing Library. - Config: `webapp-next/vitest.config.ts`; setup: `webapp-next/src/test/setup.ts`. ## Running both To run backend and frontend tests in sequence: ```bash pytest && (cd webapp-next && npm test) ``` If the user did not specify "backend only" or "frontend only", run both and report results for each. ## Scope - **Single file or dir:** `pytest path/to/test_file.py` or `pytest path/to/test_dir/`. For frontend, use Vitest’s path args as per its docs (e.g. under `webapp-next/`). - **Verbosity:** Use `pytest -v` if the user wants more detail. ## Failures - Do not send raw exception strings from tests to the user; summarize failures and point to failing test names/locations. - If pytest fails with import errors, suggest `PYTHONPATH=. pytest` and ensure the venv is activated and dev deps are installed (`pip install -r requirements-dev.txt` or `pip install -e ".[dev]"`).