unit-testinglisted
Install: claude install-skill rnavarych/alpha-engineer
# Unit Testing Patterns
## When to use
- Setting up Vitest or Jest for a new project
- Writing unit tests for business logic
- Component testing with Testing Library
- Mocking HTTP requests with MSW
- Parametrized tests with it.each
## Core principles
1. **Test behavior, not implementation** — what does it return/do, not how
2. **MSW over jest.mock** — mock at network level, not module level
3. **One assertion per test** — single reason to fail per test
4. **Arrange-Act-Assert** — consistent structure in every test
5. **No test interdependence** — each test must run independently
## References available
- `references/vitest-config.md` — globals, environment, coverage thresholds, thread pool, MSW setup
- `references/business-logic-testing.md` — pure function tests, AAA pattern, it.each parametrized tests
- `references/msw-http-mocking.md` — handlers setup, server lifecycle, per-test handler overrides
- `references/async-testing.md` — await patterns, rejected promise assertions, try/catch error checks
- `references/testing-library-react.md` — render, screen queries, userEvent vs fireEvent, role queries