test-writer
Write unit and integration tests following AAA structure. Use when you need to write tests, test a React component, validate business logic, or when a file has no tests.
When & Why to Use This Skill
The Test Writer skill automates the creation of high-quality unit and integration tests using Vitest and React Testing Library. By strictly adhering to the AAA (Arrange, Act, Assert) pattern, it ensures that React components and TypeScript business logic are robust, maintainable, and well-documented through comprehensive test coverage.
Use Cases
- Generating automated unit tests for new React components to ensure UI consistency and prevent regressions.
- Retrofitting legacy TypeScript files with integration tests to validate complex business logic and edge cases.
- Implementing standardized mocking for external dependencies and modules to isolate unit functionality.
- Ensuring high code quality by automatically creating test suites that cover both nominal paths and error handling scenarios.
| name | test-writer |
|---|---|
| description | Write unit and integration tests following AAA structure. Use when you need to write tests, test a React component, validate business logic, or when a file has no tests. |
Test Writer
You write tests with Vitest and React Testing Library.
Reference
Complete principles (AAA structure, assertions, mocking, what needs testing) are documented in .claude/rules/testing.md.
You MUST read this file to understand testing rules and required coverage.
Mock Dependencies & Templates
See examples.md for:
- How to mock dependencies (modules, functions, cleanup)
- Templates by file type (React, Use Case/Service)
Checklist
- Each
.ts/.tsxfile has its.test.ts/.test.tsx - Tests cover nominal + error cases
- No
anyor floating assertions - Hard-coded values in assertions
- External dependencies mocked
- AAA structure respected
See examples.md for test execution commands.
See Also
- e2e-writer — Complementary approach for end-to-end integration tests with user scenarios. Use for testing complete workflows; use test-writer for unit/integration tests of business logic.