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
- Unit & Integration Testing — Vitest patterns, mocking, MSW, test organization
- E2E Testing with Playwright — Page objects, selectors, assertions, parallelism, debugging
- Component Testing — React Testing Library, render patterns, user events
Backend Testing (Multi-stack)
- Backend Unit Testing — Rust (cargo test), Go, Python (pytest), Node (Jest/Vitest)
- API Integration Testing — HTTP endpoint testing, database integration, test containers
- Database Testing — Migration tests, fixtures, transaction rollback patterns
Performance & Load
- Load Testing with k6 — Scenarios, thresholds, custom metrics, CI integration
- Performance Testing — Core Web Vitals, Lighthouse CI, bundle analysis
- API Load Testing — Backend stress testing, concurrency, benchmarking
Security & Accessibility
- Security Testing — OWASP Top 10, SQL injection, XSS, CSRF, auth bypasses
- Accessibility Testing — WCAG 2.1, axe-core, keyboard nav, screen readers
Quality & Strategy
- Visual Regression — Screenshot comparison, responsive snapshots, CI workflow
- Test Strategy Guide — What to test, flakiness mitigation, test data, CI/CD gates
- Cross-Browser & Mobile — Browser matrix, device testing, responsive verification
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
1---2name: testing-43description: Comprehensive testing across platforms — Web (Playwright, Vitest), Backend (Rust/Go/Python/Node API testing), Desktop (Tauri, Electron), Mobile (React Native, Flutter - coming soon). Unit, integration, E2E, load, security, accessibility testing. Use for test automation, quality assurance, CI/CD integration.4license: MIT5---6
7# Testing Mastery
8
9Platform-agnostic testing strategy covering Web, Backend, Desktop, and Mobile applications. Core principles apply across all platforms.
10
11> **Note:** Desktop (Tauri/Electron) and Mobile (React Native/Flutter) testing guides coming soon.
12
13## Platform Coverage
14
15| Platform | Status | Frameworks |
16|----------|--------|------------|
17| **Web Frontend** | ✅ Complete | Vitest, Playwright, React Testing Library |
18| **Web Backend** | ✅ Complete | Rust (cargo test), Go, Python (pytest), Node |
19| **Desktop** | 🚧 Coming | Tauri, Electron (WebDriver) |
20| **Mobile** | 🚧 Coming | React Native (Detox), Flutter |
21
22## Testing Pyramid (70-20-10)
23
24| Layer | Ratio | Framework | Speed | What to Test |
25|-------|-------|-----------|-------|-------------|
26| Unit | 70% | Vitest | <50ms | Functions, utils, state logic |
27| Integration | 20% | Vitest + MSW | 100-500ms | API endpoints, DB ops, modules |
28| E2E | 10% | Playwright | 5-30s | Critical flows (login, checkout) |
29
30## Quick Start
31
32```bash
33# Unit tests
34npx vitest run # Run all
35npx vitest run --coverage # With coverage
36npx vitest --ui # Visual UI
37
38# E2E tests
39npx playwright test # Run all
40npx playwright test --ui # Interactive UI
41npx playwright test --headed # See browser
42npx playwright codegen https://myapp.com # Record test
43
44# Load test
45k6 run load-test.js
46
47# Accessibility
48npx @axe-core/cli https://myapp.com
49npx lighthouse https://myapp.com --output=html
50```
51
52## Reference Navigation
53
54### Frontend Testing
55- **[Unit & Integration Testing](references/unit-integration-testing.md)** — Vitest patterns, mocking, MSW, test organization
56- **[E2E Testing with Playwright](references/e2e-playwright.md)** — Page objects, selectors, assertions, parallelism, debugging
57- **[Component Testing](references/component-testing.md)** — React Testing Library, render patterns, user events
58
59### Backend Testing (Multi-stack)
60- **[Backend Unit Testing](references/backend-unit-testing.md)** — Rust (cargo test), Go, Python (pytest), Node (Jest/Vitest)
61- **[API Integration Testing](references/api-integration-testing.md)** — HTTP endpoint testing, database integration, test containers
62- **[Database Testing](references/database-testing.md)** — Migration tests, fixtures, transaction rollback patterns
63
64### Performance & Load
65- **[Load Testing with k6](references/load-testing-k6.md)** — Scenarios, thresholds, custom metrics, CI integration
66- **[Performance Testing](references/performance-testing.md)** — Core Web Vitals, Lighthouse CI, bundle analysis
67- **[API Load Testing](references/api-load-testing.md)** — Backend stress testing, concurrency, benchmarking
68
69### Security & Accessibility
70- **[Security Testing](references/security-testing.md)** — OWASP Top 10, SQL injection, XSS, CSRF, auth bypasses
71- **[Accessibility Testing](references/accessibility-testing.md)** — WCAG 2.1, axe-core, keyboard nav, screen readers
72
73### Quality & Strategy
74- **[Visual Regression](references/visual-regression.md)** — Screenshot comparison, responsive snapshots, CI workflow
75- **[Test Strategy Guide](references/test-strategy-guide.md)** — What to test, flakiness mitigation, test data, CI/CD gates
76- **[Cross-Browser & Mobile](references/cross-browser-mobile.md)** — Browser matrix, device testing, responsive verification
77
78## CI/CD Integration
79
80### Frontend Pipeline
81```yaml
82jobs:
83 test-frontend:
84 steps:
85 - run: npm run test:unit # Gate 1: Fast fail (<30s)
86 - run: npm run test:integration # Gate 2: API mocking
87 - run: npm run test:e2e # Gate 3: Critical flows
88 - run: npm run test:a11y # Gate 4: Accessibility
89 - run: npx lhci autorun # Gate 5: Performance
90```
91
92### Backend Pipeline (Rust)
93```yaml
94jobs:
95 test-backend:
96 steps:
97 - run: cargo test --lib # Unit tests
98 - run: cargo test --test '*' # Integration tests
99 - run: cargo clippy # Linting
100```
101
102### Backend Pipeline (Multi-stack)
103```yaml
104# Go
105- run: go test ./...
106- run: golangci-lint run
107
108# Python
109- run: pytest tests/
110- run: ruff check .
111
112# Node.js
113- run: npm run test
114- run: npm run lint
115```
116
117## Best Practices
118
1191. **Test behavior, not implementation** — Test what the user sees, not internal state
1202. **Arrange-Act-Assert** — Clear structure for every test
1213. **Avoid test interdependence** — Each test runs in isolation
1224. **Use factories, not fixtures** — Generate fresh test data
1235. **Flaky tests = bugs** — Fix or quarantine immediately
1246. **Coverage ≠ Quality** — 80% meaningful > 100% shallow
125
126## Related Skills
127
128| Skill | When to Use |
129|-------|-------------|
130| [rust-backend-advance](../rust-backend-advance/SKILL.md) | Rust-specific testing patterns with cargo test |
131| [nextjs-turborepo](../nextjs-turborepo/SKILL.md) | Next.js E2E testing setup |
132| [databases](../databases/SKILL.md) | Database testing, migrations |
133| [devops](../devops/SKILL.md) | CI/CD pipeline test integration |
134| [debugging](../debugging/SKILL.md) | Test failure investigation |
135| [security](../security/SKILL.md) | Security testing methodologies |