Documentation Index
Fetch the complete documentation index at: https://grantmaster.dev/llms.txt
Use this file to discover all available pages before exploring further.
Testing Strategy
| Status | Updated | Covered Directory |
|---|---|---|
| 🟢 Stable | 2026-02-16 | tests/, src/**/*.test.* |
Philosophy
GrantMaster follows a “Confidence-Driven” testing strategy. We prioritize tests that prevent regression in core business logic (grants, money, users).The Testing Pyramid
- Unit Tests (Vitest): Fast, isolated tests for utilities, formatters, and small components. Collocated with the source code.
- Integration Tests (Vitest + React Testing Library): Tests for Feature Services (
BaseServiceimplementations) and complex UI components. We mock Firestore at this level to ensure speed. - E2E Tests (Playwright): Full-flow browser tests (e.g., “Create Grant -> Approve Expense -> Verify Dashboard Update”). These run against a staging-like environment.
Technical Details
Service Layer Testing
When testingBaseService implementations, we use a specialized mock for the DataService.
- Goal: Verify that the service correctly interacts with the
EventBusandAuditLogger. - Reference: See
src/core/BaseService.test.ts.
UI Component Testing
- Theme/Context Support: Use the custom
renderfunction fromtests/testUtils.tsx. It automatically wraps components in necessary providers (Theme, Auth, i18n). - Mocking: Use
Mocksuffix for mock data to keep test code clean.
E2E Flows
Located intests/e2e. These focus on:
- Authentication & Onboarding.
- Grant Lifecycle state changes.
- Multi-tenancy leak detection (attempting to access Org B data as Org A user).
Commands
npm run test: Runs unit and integration tests via Vitest.npm run test:e2e: Runs Playwright browser tests.npm run test:coverage: Generates a code coverage report.
Maintenance
Update this document when:- Migrating from Vitest to another runner.
- Changing the standard for test collocation.
- Introducing static analysis tools like
CypressorStorybook.
Update Checklist
- Ensure
tests/README.mdis kept in sync with high-level strategy here. - Verify that
tests/testUtils.tsxexports are correctly documented.