{"manifest":{"name":"Test Generator","version":"1.0.0","description":"Analyzes source code and generates comprehensive unit tests. Auto-detects framework (Vitest/Jest/pytest/Go), handles mocking, covers edge cases.","tags":["testing","tdd","generator","devtools"],"standard":"agentskills.io","standard_version":"1.0","content_checksum":"d483e4b0f0f35a693e0c2b244990e8ee28faafb5e76476e9593601720846eb5a","bundle_checksum":null,"metadata":{},"files":[]},"files":{"SKILL.md":"# Test Generator\n\n> **Purpose:** Analyze source code and generate comprehensive unit tests following the project's testing conventions.\n\n---\n\n## Invocation\n\n```\n/test-gen <file_path> [--framework vitest|jest|pytest|go]\n```\n\n---\n\n## Process\n\n### Step 1: Analyze the Target\n\nRead the source file and identify:\n- All exported functions/classes/methods\n- Input types and return types\n- Edge cases from conditional branches\n- Dependencies that need mocking\n- Existing test file (if any) to avoid duplicates\n\n### Step 2: Determine Testing Framework\n\nAuto-detect from project config:\n- `vitest.config.*` → Vitest\n- `jest.config.*` or `package.json[jest]` → Jest\n- `pytest.ini` or `pyproject.toml[tool.pytest]` → pytest\n- `*_test.go` files → Go testing\n\n### Step 3: Generate Test Cases\n\nFor each function, generate:\n\n1. **Happy path** — typical valid input → expected output\n2. **Edge cases** — empty input, zero, null/undefined, boundary values\n3. **Error paths** — invalid input → expected error/exception\n4. **Type variations** — different valid types if function accepts union types\n\n### Step 4: Structure the Test File\n\n```typescript\nimport { describe, it, expect, vi } from 'vitest'\nimport { targetFunction } from '../path/to/source'\n\ndescribe('targetFunction', () => {\n  it('returns expected result for valid input', () => {\n    expect(targetFunction('valid')).toBe('expected')\n  })\n\n  it('throws on null input', () => {\n    expect(() => targetFunction(null)).toThrow()\n  })\n\n  it('handles empty string', () => {\n    expect(targetFunction('')).toBe('')\n  })\n})\n```\n\n---\n\n## Mocking Strategy\n\n- **External APIs**: Always mock with `vi.mock()` or `jest.mock()`\n- **Database calls**: Mock the client/ORM, not the database\n- **File system**: Mock `fs` operations, never touch real files\n- **Time**: Use `vi.useFakeTimers()` for time-dependent logic\n- **Environment variables**: Set via `vi.stubEnv()` or test setup\n\n---\n\n## Rules\n\n- Match the project's existing test style (describe/it vs test, assertion style)\n- Place test files adjacent to source (`*.test.ts`) or in `tests/` mirror\n- Never generate snapshot tests unless explicitly asked\n- Aim for branch coverage, not just line coverage\n- Each test should be independent — no shared mutable state\n- Test names should describe behavior, not implementation"}}