3.0 KiB
3.0 KiB
Testing
Current State
No tests exist yet. The codebase has zero test files — no Go tests, no frontend component tests, no E2E tests. CLAUDE.md references test commands but the infrastructure is not set up.
Planned Frameworks (from CLAUDE.md)
Backend (Go)
- Framework: Go standard library
testingpackage - Command:
cd backend && go test ./... - Package-level:
cd backend && go test ./internal/api/... - No test files exist (
*_test.go)
Frontend
- Unit/Component Testing: Vitest
- Command:
cd frontend && bun vitest - Not yet installed (missing from
package.jsondevDependencies)
- Command:
- E2E Testing: Playwright
- Command:
cd frontend && bun playwright test - Not yet installed
- Command:
Dependencies Needed
Frontend (not yet in package.json)
{
"devDependencies": {
"vitest": "^x.x.x",
"@testing-library/react": "^x.x.x",
"@testing-library/jest-dom": "^x.x.x",
"@playwright/test": "^x.x.x"
}
}
Backend
No additional dependencies needed — Go's testing package is built-in.
Configuration Files Needed
| File | Purpose |
|---|---|
frontend/vitest.config.ts |
Vitest configuration |
frontend/src/setupTests.ts |
Test environment setup |
frontend/playwright.config.ts |
E2E test configuration |
Recommended Test Structure
Backend
backend/
internal/
api/
handlers_test.go # Handler tests (HTTP request/response)
router_test.go # Route registration tests
auth/
auth_test.go # JWT and bcrypt tests
db/
queries_test.go # Database query tests (integration)
Frontend
frontend/
src/
components/
BudgetSetup.test.tsx
BillsTracker.test.tsx
...
pages/
DashboardPage.test.tsx
LoginPage.test.tsx
...
hooks/
useAuth.test.ts
useBudgets.test.ts
lib/
api.test.ts
format.test.ts
e2e/
auth.spec.ts
budget.spec.ts
Testing Patterns (Inferred from Architecture)
Backend
- HTTP handler testing: Use
net/http/httptestwith Chi router - Database testing: Integration tests against PostgreSQL (pgxpool can be mocked or use test DB)
- Auth testing: Test JWT generation/validation, bcrypt hashing
- Context-based: All handlers use
context.Contextfor user ID propagation
Frontend
- Component testing: Vitest + React Testing Library
- Hook testing:
renderHookfrom Testing Library - API mocking: Mock fetch or use MSW for
/api/*endpoints - i18n in tests: Wrap components with i18next provider
Priority Test Areas
Backend (High Priority)
- Auth flow (register, login, JWT validation, password hashing)
- Category CRUD (user isolation)
- Budget operations (carryover calculations, item copying)
- Database query correctness
- Middleware (auth required, CORS)
Frontend (High Priority)
- Auth flow (login/register forms, state management)
- Budget selection & display
- Budget item CRUD
- Currency formatting
- i18n language switching
- Form validation