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:
| Fixture | Description |
|---|---|
user | A test user instance |
other_user | A second user (for ownership tests) |
api_client | Unauthenticated DRF API client |
auth_client | API client authenticated as user |
other_auth_client | API 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(notsetupFilesAfterSetup) - 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:
- Server tests (
pytest) - Mobile lint (
eslint) - Mobile type-check (
tsc) - Mobile tests (
jest)