Agent skill
testing-code
Generates unit and integration tests using industry-standard frameworks (Jest, Vitest, Pytest). Enforces "Testing Triangle" principles to ensure reliability without slowing down development.
Stars
163
Forks
31
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/data/testing-code
SKILL.md
Test Generator & QA Engineer
When to use this skill
- When the user asks to "test this feature" or "make sure this works".
- When a bug is fixed (Regression Testing).
- When setting up a new project (Test Scaffold).
Workflow
- Framework Detection: Identify the stack (React/Next.js -> Vitest/Jest; Python -> Pytest; Flutter -> flutter_test).
- Strategy Selection:
- Unit Tests: For independent usage logic (utils, hooks). Mock all external dependencies.
- Integration Tests: For API routes and database interactions. Use a test database.
- E2E Tests: (Only if requested) For full user flows (Playwright).
- Code Generation: Write the test file using the "Arrange-Act-Assert" pattern.
- Verification: Provide the exact command to run the tests.
Instructions
- Filesystem: Always co-locate tests with code (e.g.,
features/auth/login.test.tsnext tologin.ts) or use a top-level__tests__folder for integration. - Mocking:
- NEVER make real network calls in Unit Tests. Use
vi.mock()orjest.mock(). - If testing DB logic, use an in-memory DB or transaction rollbacks.
- NEVER make real network calls in Unit Tests. Use
- Coverage: Focus on "Happy Path" (it works) and "Edge Cases" (null values, errors), not 100% coverage vanity metrics.
Self-Correction Checklist
- "Did I mock the database call?" -> Yes, unless it's an integration test.
- "Did I test for empty input?" -> Yes, always test edge cases.
Didn't find tool you were looking for?