Skip to main content

Overview

ondoki has three test layers:
LayerToolDirectory
Backendpytest + pytest-asyncioapi/tests/
FrontendJestapp/tests/unit/, app/src/**/__tests__/
E2EPlaywrightapp/tests/e2e/

Running All Tests

make test   # Runs backend + frontend tests

Backend Tests

Backend tests run inside Docker using pytest with async support.
# Via Makefile (recommended — runs inside Docker)
make test-backend

# Or manually (local)
cd api
python -m pytest tests/ -v

How It Works

The Makefile:
  1. Creates a ondoki_test database (if it doesn’t exist)
  2. Enables the vector extension
  3. Runs pytest inside the backend container with test-specific environment variables

Test Configuration

VariableDefaultDescription
DATABASE_URL_TEST(auto-composed)Test database connection string
TEST_DB_NAMEondoki_testTest database name
ONDOKI_ENCRYPTION_KEYTest keyEncryption key for tests
JWT_SECRETtest-secretJWT secret for tests

pytest Configuration

From pyproject.toml:
[tool.pytest.ini_options]
asyncio_mode = "auto"
asyncio_default_fixture_loop_scope = "session"
All async tests run automatically without needing @pytest.mark.asyncio.

Key Dependencies

  • pytest >= 8.0
  • pytest-asyncio >= 1.0.0
  • testcontainers 4.10.0 (for isolated database containers)

Frontend Tests

Frontend unit tests use Jest.
# Via Makefile
make test-frontend

# Or manually
cd app
npx jest --passWithNoTests

# Or with pnpm
cd app
pnpm test

Test Location

Tests can be placed in:
  • app/tests/unit/ — dedicated test directory
  • app/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.
make test-e2e

How It Works

The Makefile:
  1. Creates the test database
  2. Starts a test-backend service on port 8001 (isolated from dev)
  3. Waits for the test backend to be healthy
  4. Runs Alembic migrations on the test database
  5. Runs Playwright tests (which start their own frontend on port 5174)
  6. Stops the test backend after tests complete

E2E Configuration

VariableValue
API_URLhttp://localhost:8001
PLAYWRIGHT_BASE_URLhttp://localhost:5174
VITE_API_URLhttp://localhost:8001
VITE_API_BASE_URLhttp://localhost:8001/api/v1

Running Specific Tests

# Run a specific test file
make test-e2e ARGS="tests/e2e/login.spec.ts"

# Run tests with a specific tag
make test-e2e ARGS="--grep 'login'"

Linting

make lint
This runs:
  • 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:
# Create the test database manually
make test-db
This creates the database and enables the vector extension if they don’t exist.

CI

Tests run automatically on pull requests via GitHub Actions. The CI pipeline runs:
  1. Backend tests (pytest)
  2. Frontend tests (Jest)
  3. Linting (ruff + tsc)