Claude-skill-registry add-test-whatifwedigdeeper-application-tracker
Add unit tests for a component or function
install
source · Clone the upstream repo
git clone https://github.com/majiayu000/claude-skill-registry
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/majiayu000/claude-skill-registry "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/data/add-test-whatifwedigdeeper-application-tracker" ~/.claude/skills/majiayu000-claude-skill-registry-add-test-whatifwedigdeeper-application-tracker && rm -rf "$T"
manifest:
skills/data/add-test-whatifwedigdeeper-application-tracker/SKILL.mdsource content
Add Tests: $ARGUMENTS
Create comprehensive unit tests for the specified component or function.
Process
1. Locate Source File
Search in order:
(React component)components/$ARGUMENTS.tsx
(utility function)lib/$ARGUMENTS.ts
(page component)app/$ARGUMENTS.tsx
2. Analyze Source
Read the file to identify:
- Exported functions/components
- Props interfaces
- State management
- Event handlers
- Key functionality to test
3. Create Test File
Place test adjacent to source:
[name].test.tsx or [name].test.ts
4. Generate Tests
For React components:
import { render, screen, fireEvent } from '@testing-library/react'; import ComponentName from './ComponentName'; describe('ComponentName', () => { test('renders correctly', () => { render(<ComponentName />); expect(screen.getByTestId('component-name')).toBeInTheDocument(); }); test('handles user interaction', () => { render(<ComponentName />); fireEvent.click(screen.getByRole('button')); // assert expected behavior }); test('handles empty state', () => { /* ... */ }); test('handles error state', () => { /* ... */ }); });
For utility functions:
import { functionName } from './fileName'; describe('functionName', () => { test('returns expected output', () => { expect(functionName(input)).toBe(expected); }); test('handles empty input', () => { /* ... */ }); test('handles edge cases', () => { /* ... */ }); test('throws on invalid input', () => { expect(() => functionName(invalid)).toThrow(); }); });
5. Run Tests
npm test -- $ARGUMENTS.test
Fix any failures, then report results.
Coverage Requirements
- Happy path scenarios
- Edge cases (empty, null, boundary values)
- Error states
- User interactions (for components)
- Accessibility (keyboard navigation)
Best Practices
- Use
for stable selectorsdata-testid - Mock localStorage if needed
- Tests should be independent and deterministic
- Descriptive test names that explain the scenario