About writing-tests
writing-tests is a testing skill for developers that helps choose test types and organize coverage around user-visible behavior and risk. It includes query and test-structure guidance, plus pointers to mocking and coverage details.
Key features
- 01Risk-based test prioritization
- 02Unit, integration, and E2E guidance
- 03Arrange-Act-Assert pattern
- 04Accessible query selection
- 05Colocated test file layout
- 06Minimum viable testing guidance
Use cases
- 01Choosing test types for a feature
- 02Prioritizing authentication and checkout tests
- 03Testing behavior in UI components
- 04Planning tests when time is limited
Install
Copy the command and run it in a terminal.
$
npx skills add https:/ / github.com/ augmnt/ webdev-skills --skill writing-testsAfter installing, type/writing-testsin Claude Code to confirm it loaded.
Bundled filesMOCKING.md
Details
From the project READMEWriting Tests
Test behavior, not implementation. Prioritize by risk.
When to Use Each Type
| 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 |
Always Test
- Auth flows
- Payment/checkout
- Data mutations (create, update, delete)
- Authorization rules
- Critical business logic
Rarely Test
- Static content
- Third-party internals
- Pure styling
File Organization
src/components/Button/
├── Button.tsx
└── Button.test.tsx # Colocated
e2e/ # E2E at root
├── auth.spec.ts
└── checkout.spec.ts
Patterns
Arrange-Act-Assert
test('increments on click', () => {
// Arrange
render(<Counter initial={0} />)
// Act
fireEvent.click(screen.getByRole('button'))
// Assert
expect(screen.getByText('1')).toBeInTheDocument()
})
Query Priority (best → worst)
getByRole- semantic, accessiblegetByLabelText- form inputsgetByText- contentgetByTestId- last resort
Test Behavior, Not Implementation
// ❌ Implementation
expect(component.state.isOpen).toBe(true)
// ✅ Behavior
expect(screen.getByRole('dialog')).toBeVisible()
Minimum Viable Testing
If time-constrained:
- E2E for happy paths (covers most ground)
- Unit for complex logic (catches edge cases)
- Integration for critical components (forms, data)
Advanced Patterns
For API mocking, test fixtures, and coverage guidance, see MOCKING.md.
Comments
Markdown supported