Skip to main content

Testing

Running Tests

All Tests

just test             # Run server + mobile tests via Docker
just check # Full suite: lint + type-check + tests

Server Tests (pytest)

# Via Docker (recommended)
just test-server
just test-server -k "test_auth" # Run specific tests
just test-server -v # Verbose output

# Locally
cd apps/server
uv run pytest -v
uv run pytest -k "test_transaction" # Filter by name
uv run pytest --cov # With coverage

Current count: 87 tests passing.

Mobile Tests (Jest)

# Via Docker
just test-mobile

# Locally
cd apps/mobile-client
pnpm test
pnpm test -- --watch # Watch mode
pnpm test -- --coverage # With coverage

Current count: 61 tests passing.

Type Checking & Linting

just type-check       # TypeScript type-check (mobile)
just lint # ESLint (mobile)

# Locally
cd apps/mobile-client
pnpm type-check
pnpm lint

Server Test Fixtures

Shared fixtures are defined in apps/server/conftest.py:

FixtureDescription
userA test user instance
other_userA second user (for ownership tests)
api_clientUnauthenticated DRF API client
auth_clientAPI client authenticated as user
other_auth_clientAPI client authenticated as other_user

Example Server Test

def test_list_transactions(auth_client, user):
Transaction.objects.create(user=user, amount=100, type="expense", date="2024-01-01")
response = auth_client.get("/api/v1/transactions/")
assert response.status_code == 200
assert len(response.data["results"]) == 1

Mobile Test Setup

  • Jest config key is setupFilesAfterEnv (not setupFilesAfterSetup)
  • Native module mocks are in __mocks__/ directories
  • Repository tests use an in-memory SQLite database
  • Component tests use React Testing Library

Example Mobile Test

describe("TransactionRepository", () => {
it("should insert a transaction", async () => {
const tx = await insertTransaction(db, {
type: "expense",
amount: 100,
date: "2024-01-01",
});
expect(tx).toBeDefined();
});
});

CI

Tests run automatically via GitHub Actions on push to main and on pull requests. The CI pipeline runs:

  1. Server tests (pytest)
  2. Mobile lint (eslint)
  3. Mobile type-check (tsc)
  4. Mobile tests (jest)