nembie/claude-code-skills/test-generator
Claude Code and agent skill by nembie/claude-code-skills
- community
- ext:[{"type":"hook","description":"Pre/post lifecycle hooks"}]
Checking that the SKILL.md file is still in the repository.
Generate unit and integration tests for API routes, utilities, React components, and hooks. Use when asked to generate tests, write unit tests, create integration tests, add test coverage, or test a component/route/function.
Install
npx vskill@latest install nembie/claude-code-skills/test-generatorSemi-extensibleMentions customization, but needs skill-specific knowledge. Read the extensible skills standard
SKILL.md
Test Generator
Before generating any output, read config/defaults.md and adapt all patterns, imports, and code examples to the user's configured stack.
Process
- Read the source file to understand its exports, dependencies, and behavior.
- Identify the source type: API route, utility function, React component, or hook.
- Generate test cases covering: happy path, edge cases, error handling, boundary values.
- Write the test file using Vitest syntax (fall back to Jest if the project uses it).
- Include proper mocking, setup/teardown, and descriptive test names.
File Naming and Placement
- Place test file adjacent to source:
foo.ts→foo.test.ts,Foo.tsx→Foo.test.tsx. - If the project uses a
__tests__/directory convention, follow that instead. - For API route tests:
app/api/users/route.ts→app/api/users/route.test.ts.
Testing API Routes
Analyze the route handler and generate tests for each HTTP method.
API Route Test Checklist
- [ ] Each HTTP method has at least one happy path test
- [ ] Invalid request body returns 400
- [ ] Missing/invalid auth returns 401
- [ ] Forbidden access returns 403
- [ ] Resource not found returns 404
- [ ] Duplicate/conflict returns 409
- [ ] Unexpected errors return 500 (not leak stack traces)
Testing Utility Functions
Focus on pure logic, null/undefined handling, and thrown errors.
Testing React Components
Use React Testing Library. Prefer getByRole over getByTestId.
Component Test Checklist
- [ ] Renders without crashing
- [ ] Displays correct content based on props
- [ ] Interactive elements respond to user events
- [ ] Conditional rendering works for all states (loading, error, empty, success)
- [ ] Accessible: interactive elements have roles and labels
- [ ] Form submission calls handler with correct values
- [ ] Error states display properly
Testing Hooks
Wrap custom hooks with renderHook from React Testing Library.
Mocking Patterns
Mock a module
Mock next/navigation
Mock fetch
Test Naming Convention
Use descriptive names following the pattern: should [expected behavior] when [condition].
should return 401 when auth token is missingshould render loading spinner when data is fetchingshould throw TypeError when input is not a string
Output Format
Verification Loop
After generating tests, run them with the project's test runner. If any test fails due to a generation error (not a legitimate bug), analyze the failure, fix the test, and re-run. Repeat up to 3 times. If a test fails because it caught a real bug in the source code, flag it clearly in the output: REAL BUG FOUND: [description]. Only deliver tests that either pass or explicitly flag real bugs.
Reference
See references/testing-patterns.md for Vitest setup, Prisma mocking, and MSW patterns.
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewNot runA model review is scheduled for the next rescan.
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/test-generator/SKILL.md
Popularity
- Repository stars
- 3
- 7-day trend score
- 7
Stars and forks are for the whole GitHub repository, not this skill alone. Refreshed 30 Mar 2026, 8 months ago.
Extension points
hookPre/post lifecycle hooks
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/nembie/claude-code-skills/test-generator)