Skip to main content

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

StatusUpdatedCovered Directory
🟢 Stable2026-02-16tests/, 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

  1. Unit Tests (Vitest): Fast, isolated tests for utilities, formatters, and small components. Collocated with the source code.
  2. Integration Tests (Vitest + React Testing Library): Tests for Feature Services (BaseService implementations) and complex UI components. We mock Firestore at this level to ensure speed.
  3. 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 testing BaseService implementations, we use a specialized mock for the DataService.
  • Goal: Verify that the service correctly interacts with the EventBus and AuditLogger.
  • Reference: See src/core/BaseService.test.ts.

UI Component Testing

  • Theme/Context Support: Use the custom render function from tests/testUtils.tsx. It automatically wraps components in necessary providers (Theme, Auth, i18n).
  • Mocking: Use Mock suffix for mock data to keep test code clean.

E2E Flows

Located in tests/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 Cypress or Storybook.

Update Checklist

  1. Ensure tests/README.md is kept in sync with high-level strategy here.
  2. Verify that tests/testUtils.tsx exports are correctly documented.