Guides test creation with practical strategies for unit, integration, and e2e tests. Use when writing tests, deciding what to test, setting up test infrastructure, or discussing coverage. Triggers on ”write tests”, ”should I test”, ”test coverage”, or test file creation.
npx playbooks add skill augmnt/webdev-skills --skill writing-tests
Test behavior, not implementation. Prioritize by risk.
| Type | What | When | Tools |
|------|------|------|-------|
| Unit | Single function/hook | Pure logic, calculations | Vitest, Jest |
| Integration | Component + deps | Forms, data display | Testing Library |
| E2E | Full user flow | Critical paths | Playwright |
src/components/Button/
├── Button.tsx
└── Button.test.tsx # Colocated
e2e/ # E2E at root
├── auth.spec.ts
└── checkout.spec.ts
test('increments on click', () => {
// Arrange
render(<Counter initial={0} />)
// Act
fireEvent.click(screen.getByRole('button'))
// Assert
expect(screen.getByText('1')).toBeInTheDocument()
})
getByRole - semantic, accessiblegetByLabelText - form inputsgetByText - contentgetByTestId - last resort// ❌ Implementation
expect(component.state.isOpen).toBe(true)
// ✅ Behavior
expect(screen.getByRole('dialog')).toBeVisible()
If time-constrained:
For API mocking, test fixtures, and coverage guidance, see [MOCKING.md](MOCKING.md).
Weekly roundup of top Claude Code skills, MCP servers, and AI coding tips.