# Test Writer Skill

## Purpose
Generate comprehensive unit and integration tests using TDD methodology.

## Instructions

### RED Phase — Write Failing Tests First
1. Analyze the function signature, types, and documented behavior
2. Write tests covering:
   - Happy path (expected inputs → expected outputs)
   - Edge cases (empty, null, boundary values)
   - Error cases (invalid inputs, exceptions)
3. Run tests to confirm they fail for the right reasons

### GREEN Phase — Minimal Implementation
1. Write the simplest code that makes all tests pass
2. Do not optimize or refactor yet
3. Verify all tests pass

### REFACTOR Phase — Clean Up
1. Remove duplication in both code and tests
2. Improve naming and structure
3. Ensure all tests still pass

## Test Patterns
- Use descriptive test names: `it("returns empty array when input is null")`
- One assertion per test when possible
- Use factories/fixtures for complex test data
- Mock external dependencies at boundaries

## Example
```typescript
describe("calculateDiscount", () => {
  it("applies 10% discount for orders over $100", () => {
    expect(calculateDiscount(150)).toBe(135);
  });

  it("returns original price for orders under $100", () => {
    expect(calculateDiscount(50)).toBe(50);
  });

  it("throws for negative amounts", () => {
    expect(() => calculateDiscount(-1)).toThrow("Invalid amount");
  });
});
```