ADR-006: Testing Strategy
Status
Accepted
Context
The application needs a comprehensive testing strategy that:
- Validates config-driven UI: Ensure configs render correctly
- Tests API integration: Proxy and authentication flows
- Supports CI/CD: Fast, reliable automated tests
- Enables component development: Isolated component testing
Options considered:
- Jest + React Testing Library: Standard React testing
- Vitest + Testing Library: Faster, Vite-native
- Playwright/Cypress: E2E browser testing
Decision
We will use a multi-layer testing approach:
1. Unit Tests (Vitest + React Testing Library)
For components and utilities:
// components/Button.test.tsx
import { render, screen } from '@testing-library/react';
import { Button } from './Button';
test('renders button with text', () => {
render(<Button>Click me</Button>);
expect(screen.getByRole('button')).toHaveTextContent('Click me');
});
2. Integration Tests (Vitest)
For store and API integration:
// store/store.test.ts
import { createGlobalStore } from './createGlobalStore';
import { testConfig } from '../fixtures/testConfig';
test('creates store from config', () => {
const store = createGlobalStore(testConfig);
expect(store.getState().user).toEqual(testConfig.store.user.initialState);
});
3. E2E Tests (Playwright)
For critical user flows:
// e2e/auth.spec.ts
import { test, expect } from '@playwright/test';
test('user can sign in', async ({ page }) => {
await page.goto('/');
await page.click('text=Sign In');
// ... auth flow
await expect(page.locator('[data-testid="user-menu"]')).toBeVisible();
});
Consequences
Positive
- Fast feedback: Unit tests run in milliseconds
- Confidence: Multiple test layers catch different issues
- CI integration: All tests run in GitHub Actions
Negative
- Maintenance: Multiple test frameworks to maintain
- Setup complexity: Initial configuration overhead
- Flaky E2E: Browser tests can be unreliable
Neutral
- Coverage goals: 80% unit, critical paths E2E
- Test data: Fixtures and factories needed