Run Tests
How to Run Tests
Section titled “How to Run Tests”This guide shows you how to run tests in various scenarios and troubleshoot common issues.
Quick Start
Section titled “Quick Start”-
Navigate to the API directory
Terminal window cd idx-api -
Run all tests with coverage
Terminal window make test -
View the HTML reports
Terminal window make test-htmlopen reports/html/report.html
Run All Tests
Section titled “Run All Tests”cd idx-api
# Run all tests with coveragemake test
# Run tests without coverage (faster)make test-fast
# Run with HTML report generationmake test-htmlRun Specific Test Categories
Section titled “Run Specific Test Categories”# Run only authentication testsmake test-auth
# Run only unit testsmake test-unit
# Run only integration testsmake test-integration
# Run tests matching patternuv run pytest -k "auth" -v
# Run specific test fileuv run pytest tests/test_agents.py -vRun with Auto-Reload
Section titled “Run with Auto-Reload”During active development, use watch mode to automatically run tests when files change:
make test-watchGenerate Coverage Reports
Section titled “Generate Coverage Reports”# Generate coverage with HTML reportmake test-coverage
# Generate coverage for specific modulesuv run pytest tests/ --cov=idx_api.routers.agents --cov-report=html
# View coverage in terminaluv run pytest tests/ --cov=idx_api --cov-report=term-missingRun Tests in Docker
Section titled “Run Tests in Docker”From the project root:
# Run tests in Docker containermake test-docker
# Run tests and publish to docs sitemake docs-publishUsing Docker Compose directly:
# Run tests with the test profiledocker compose --profile test run --rm idx-api-test
# View test reports in docs dev serverdocker compose --profile dev up idx-docs-dev# Reports available at: https://help.{DOMAIN}/reports/tests/report.htmlPublish Reports to Docs
Section titled “Publish Reports to Docs”Test reports can be published to this documentation site for team visibility:
-
Generate fresh reports
Terminal window make test-html -
Publish to docs
Terminal window make publish-docs -
Or combine both steps
Terminal window make test-publish
Published reports are available at:
Set Up CI/CD
Section titled “Set Up CI/CD”With Docker
Section titled “With Docker”# GitHub Actions example with Dockerjobs: test: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4
- name: Run tests in Docker run: make test-docker
- name: Build docs with reports run: make docs-build
- name: Deploy docs run: docker compose --profile prod up -d idx-docsWithout Docker
Section titled “Without Docker”# GitHub Actions example (local)- name: Run tests run: | cd idx-api make test-html
- name: Upload reports uses: actions/upload-artifact@v4 with: name: test-reports path: idx-api/reports/Troubleshooting
Section titled “Troubleshooting”Common Issues
Section titled “Common Issues”# Ensure package is installed in dev modecd idx-apiuv pip install -e ".[dev]"# Tests use in-memory SQLite by default# If you see "table not found" errors:uv run alembic upgrade head# Ensure pytest-asyncio is configured# Check pyproject.toml has:# [tool.pytest.ini_options]# asyncio_mode = "auto"Debug Failed Tests
Section titled “Debug Failed Tests”# Run single test with verbose outputuv run pytest tests/test_auth.py::test_api_key_validation -vvv
# Show print statementsuv run pytest -s
# Drop into debugger on failureuv run pytest --pdb
# Show local variables in tracebackuv run pytest --tb=long