drafael/coding-harness / skills/write-tests
write-tests
VerifiedWrite unit, integration, component, and end-to-end tests for code. Use when the user asks to "write tests", "add tests", "add test coverage", or "create test cases" for functions, services, components, CLIs, or user flows.
| File | Kind | Size |
|---|---|---|
| README.md | markdown | 1.3 KB |
| SKILL.md | skill md | 3.6 KB |
| references/bun-test.md | markdown | 4.5 KB |
| references/jest.md | markdown | 4.7 KB |
| references/junit.md | markdown | 1.6 KB |
| references/node-test.md | markdown | 4.1 KB |
| references/playwright.md | markdown | 5.7 KB |
| references/typescript.md | markdown | 5.7 KB |
| references/vitest.md | markdown | 4.4 KB |
SKILL.md
View on GitHub---
name: write-tests
description: Write unit, integration, component, and end-to-end tests for code. Use when the user asks to "write tests", "add tests", "add test coverage", or "create test cases" for functions, services, components, CLIs, or user flows.
allowed-tools: Read, Grep, Glob, Bash, Write, Edit
---
# Write Tests
Write the appropriate unit, integration, component, and end-to-end tests: **$ARGUMENTS**
## Process
Follow these steps in order:
1. **Understand the project's test conventions**
- Identify the language, runtime, package boundary, and every test runner relevant to the requested tests
- Inspect dependencies, imports, runner configuration, package scripts, setup files, CI commands, and representative existing tests
- Load every matching language and runner reference that exists:
- `references/junit.md`
- `references/typescript.md`
- `references/vitest.md`
- `references/jest.md`
- `references/node-test.md`
- `references/bun-test.md`
- `references/playwright.md`
- In monorepos and migrations, determine runner ownership per package and test file; do not assume one runner governs the repository
- Repository conventions and installed-version behavior override greenfield defaults
2. **Analyse the code under test**
- Identify the public interface and critical business logic
- Map dependencies and external interactions
- Note error conditions, edge cases, and validation rules
- Follow repository coverage thresholds and use coverage to identify consequential gaps rather than gaming a universal percentage
3. **Plan the test strategy**
- Decide which levels are needed: unit, integration, end-to-end
- List what to mock or stub, and why
- Prioritise business-critical paths first
4. **Write unit tests**
- Test cohesive units through the smallest stable public or package boundary; tests do not need to map one-to-one to functions or methods
- Cover relevant happy paths, edge cases, boundary conditions, and error/exception paths
- Follow the AAA pattern (Arrange / Act / Assert) — use blank lines to separate phases, never write `// Arrange` comments
- Use descriptive test names that explain the scenario being tested
- Keep each test focused on one behaviour; avoid assertions on unrelated state
5. **Write integration tests**
- Test real interactions among application-owned components and controlled dependencies such as in-process APIs, test databases, sandboxes, or contract servers
- Do not contact production or uncontrolled live third-party services by default
- Verify data flow across meaningful layer boundaries
- Cover failure modes and partial failures, not just the happy path
6. **Write component or end-to-end tests when needed**
- Exercise observable user behavior through framework-supported test APIs
- Keep critical cross-boundary flows in E2E tests and lower-level edge cases in faster tests
- Preserve accessibility, isolation, cleanup, and supported runtime/browser coverage
7. **Mocking and test data**
- Mock external dependencies to keep unit tests fast and deterministic
- Avoid over-mocking — if a mock replicates production logic, use a real object instead
- Use factories or builders for complex test data; keep setup out of assertion code
- Ensure tests are isolated — no shared mutable state between cases
8. **Apply applicable specialist concerns**
- **Async code**: use the framework's async test utilities; test both resolution and rejection
- **Security**: cover auth checks, input validation, and access control boundaries
- **UI**: test rendered output, keyboard navigation, and ARIA semantics where relevant
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| finishing-a-development-branchobra/superpowersUse when implementation is complete, all tests pass, and you need to decide how to integrate the work | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| systematic-debuggingobra/superpowersUse when encountering any bug, test failure, or unexpected behavior, before proposing fixes | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| test-driven-developmentobra/superpowersUse when implementing any feature or bugfix, before writing implementation code | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| skill-creatoranthropics/skillsCreate new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an existing skill, run evals to test a skill, benchmark skill performance with variance analysis, or optimize a skill's description for better triggering accuracy. | Stars: 197k | Updated | Claude CodeCodex | Verified | Install |