Testing Mastery
Platform-agnostic testing strategy covering Web, Backend, Desktop, and Mobile applications. Core principles apply across all platforms.
Note: Desktop (Tauri/Electron) and Mobile (React Native/Flutter) testing guides coming soon.
Platform Coverage
| Platform | Status | Frameworks |
|---|
| Web Frontend | ✅ Complete | Vitest, Playwright, React Testing Library |
| Web Backend | ✅ Complete | Rust (cargo test), Go, Python (pytest), Node |
| Desktop | 🚧 Coming | Tauri, Electron (WebDriver) |
| Mobile | 🚧 Coming | React Native (Detox), Flutter |
Testing Pyramid (70-20-10)
| Layer | Ratio | Framework | Speed | What to Test |
|---|
| Unit | 70% | Vitest | <50ms | Functions, utils, state logic |
| Integration | 20% | Vitest + MSW | 100-500ms | API endpoints, DB ops, modules |
| E2E | 10% | Playwright | 5-30s | Critical flows (login, checkout) |
Quick Start
# Unit tests
npx vitest run # Run all
npx vitest run --coverage # With coverage
npx vitest --ui # Visual UI
# E2E tests
npx playwright test # Run all
npx playwright test --ui # Interactive UI
npx playwright test --headed # See browser
npx playwright codegen https://myapp.com # Record test
# Load test
k6 run load-test.js
# Accessibility
npx @axe-core/cli https://myapp.com
npx lighthouse https://myapp.com --output=html
Reference Navigation
Frontend Testing
Backend Testing (Multi-stack)
Performance & Load
Security & Accessibility
Quality & Strategy
CI/CD Integration
Frontend Pipeline
jobs:
test-frontend:
steps:
- run: npm run test:unit # Gate 1: Fast fail (<30s)
- run: npm run test:integration # Gate 2: API mocking
- run: npm run test:e2e # Gate 3: Critical flows
- run: npm run test:a11y # Gate 4: Accessibility
- run: npx lhci autorun # Gate 5: Performance
Backend Pipeline (Rust)
jobs:
test-backend:
steps:
- run: cargo test --lib # Unit tests
- run: cargo test --test '*' # Integration tests
- run: cargo clippy # Linting
Backend Pipeline (Multi-stack)
# Go
- run: go test ./...
- run: golangci-lint run
# Python
- run: pytest tests/
- run: ruff check .
# Node.js
- run: npm run test
- run: npm run lint
Best Practices
- Test behavior, not implementation — Test what the user sees, not internal state
- Arrange-Act-Assert — Clear structure for every test
- Avoid test interdependence — Each test runs in isolation
- Use factories, not fixtures — Generate fresh test data
- Flaky tests = bugs — Fix or quarantine immediately
- Coverage ≠ Quality — 80% meaningful > 100% shallow
Related Skills