Overview
ondoki has three test layers:| Layer | Tool | Directory |
|---|---|---|
| Backend | pytest + pytest-asyncio | api/tests/ |
| Frontend | Jest | app/tests/unit/, app/src/**/__tests__/ |
| E2E | Playwright | app/tests/e2e/ |
Running All Tests
Backend Tests
Backend tests run inside Docker using pytest with async support.How It Works
The Makefile:- Creates a
ondoki_testdatabase (if it doesn’t exist) - Enables the
vectorextension - Runs pytest inside the backend container with test-specific environment variables
Test Configuration
| Variable | Default | Description |
|---|---|---|
DATABASE_URL_TEST | (auto-composed) | Test database connection string |
TEST_DB_NAME | ondoki_test | Test database name |
ONDOKI_ENCRYPTION_KEY | Test key | Encryption key for tests |
JWT_SECRET | test-secret | JWT secret for tests |
pytest Configuration
Frompyproject.toml:
@pytest.mark.asyncio.
Key Dependencies
pytest>= 8.0pytest-asyncio>= 1.0.0testcontainers4.10.0 (for isolated database containers)
Frontend Tests
Frontend unit tests use Jest.Test Location
Tests can be placed in:app/tests/unit/— dedicated test directoryapp/src/**/__tests__/— co-located with source files
End-to-End Tests
E2E tests use Playwright and run against a dedicated test backend with an isolated database.How It Works
The Makefile:- Creates the test database
- Starts a
test-backendservice on port 8001 (isolated from dev) - Waits for the test backend to be healthy
- Runs Alembic migrations on the test database
- Runs Playwright tests (which start their own frontend on port 5174)
- Stops the test backend after tests complete
E2E Configuration
| Variable | Value |
|---|---|
API_URL | http://localhost:8001 |
PLAYWRIGHT_BASE_URL | http://localhost:5174 |
VITE_API_URL | http://localhost:8001 |
VITE_API_BASE_URL | http://localhost:8001/api/v1 |
Running Specific Tests
Linting
- Backend:
ruff check .(Python linting) - Frontend:
tsc --noEmit(TypeScript type checking)
Test Database
The test database (ondoki_test) is separate from the development database (ondoki). It uses the same PostgreSQL instance but is isolated:
vector extension if they don’t exist.
CI
Tests run automatically on pull requests via GitHub Actions. The CI pipeline runs:- Backend tests (pytest)
- Frontend tests (Jest)
- Linting (ruff + tsc)