Agent skill
component-tester
Run Vitest tests for a specific component with coverage. Use when making changes to React components to ensure tests pass and coverage is maintained.
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/development/component-tester
SKILL.md
Component Tester Skill
This Skill automatically runs Vitest tests when React components are modified to ensure code quality and test coverage.
When to Activate
- After creating a new React component
- When modifying existing component implementation
- Before creating a pull request with component changes
- When fixing bugs in components
Actions Performed
- Identify Component: Determine which component was created or modified
- Run Tests: Execute
pnpm test -- <component-path>without watch mode - Check Coverage: Verify test coverage meets project thresholds
- Report Results: Provide clear feedback on:
- Test pass/fail status
- Coverage percentages (statements, branches, functions, lines)
- Specific failing tests with error messages
- Coverage gaps requiring additional tests
Example Usage
// User modifies: src/app/blog/_components/progress-bar.tsx
// Skill automatically runs:
// pnpm test -- src/app/blog/_components/progress-bar
// Output:
// ✓ should render progress bar with correct width
// ✓ should update progress on scroll
// ✓ should hide when not scrolled
// Coverage: 95% statements, 90% branches, 100% functions, 95% lines
Tools Used
- Read: Examine component files and test files
- Grep: Locate related test files
- Bash: Execute
pnpm testcommands
Test Naming Convention
All tests should follow the "should" convention:
- ✅ "should render title and children"
- ✅ "should display empty state when data is empty"
- ❌ "renders title and children"
Coverage Thresholds
Flag components with coverage below:
- Statements: 80%
- Branches: 75%
- Functions: 80%
- Lines: 80%
Related Files
- Test location:
__tests__/directories next to components - Test suffix:
.test.tsor.test.tsx - Configuration:
vitest.config.tsin project root
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
Didn't find tool you were looking for?