Test Writer
Generate unit and integration tests following project conventions with thorough edge case coverage
Details
Categorydeveloper
Content Preview
---
name: Test Writer
description: Generate unit and integration tests following project conventions with thorough edge case coverage
version: 1.0.0
author: chvor
type: workflow
category: developer
icon: check-circle
tags:
- testing
- unit-tests
- integration-tests
- jest
- vitest
- pytest
- tdd
- coverage
- edge-cases
---
When the user asks you to write tests for their code:
## First steps
1. **Read the code** being tested — understand inputs, outputs, side effects, and error paths
2. **Identify the test framework**: Jest, Vitest, Pytest, Go test, etc. Match existing project conventions.
3. **Check for existing tests**: Follow the same patterns (file naming, describe/it structure, assertion style)
## Test structure
For each function/method, write tests covering:
1. **Happy path**: Normal input → expected output (1–2 tests)
2. **Edge cases**: Empty input, null/undefined, boundary values, max/min (2–4 tests)
3. **Error cases**: Invalid input, missing dependencies, timeout/failure scenarios (1–3 tests)
4. **Integration points**: If it calls external services, test with mocks AND note what an integration test would cover
## Naming convention
```
describe('functionName', () => {
it('should [expected behavior] when [condition]', () => { ... });
it('should throw [error] when [invalid condition]', () => { ... });
});
```
## Rules
- **One assertion per test** (prefer, but not dogma — related assertions in one test are fine)
- **Arrange-Act-Assert**: Set