// Generate comprehensive test suites, identify coverage gaps, and accelerate progress toward 70% test coverage goal with intelligent test recommendations
| name | Test Generation |
| description | Generate comprehensive test suites, identify coverage gaps, and accelerate progress toward 70% test coverage goal with intelligent test recommendations |
This skill helps you dramatically improve test coverage from the current 48% toward the 70% goal by intelligently generating tests where they're needed most and providing coverage analysis.
Claude will automatically invoke this skill when:
📊 Test Coverage Baseline
├── Total Tests: 481
├── Statement Coverage: 47.82%
├── Line Coverage: 48.28%
├── Function Coverage: 39%
├── Branch Coverage: 36.19%
├── Target: 70% (Need +22% improvement)
└── Estimated Untested Components: 15-20
# Run all tests
npm test
# Run tests in watch mode for development
npm run test:watch
# Generate coverage report (shows gaps)
npm run test:coverage
# Run only pattern data tests
npm run test:patterns
# Run only component tests
npm run test:components
# CI mode with coverage (no watch)
npm run test:ci
npm run test:coverage
Output shows:
Tests to prioritize (highest impact first):
UI Components (high usage, visible impact)
Interactive Example Components (demo components for patterns)
Context Providers (critical state management)
Custom Hooks (reusable logic)
Utility Functions (pure logic)
Edge Cases & Error Handling
For each component without sufficient tests:
npm run generate-test
When prompted, specify:
Buttonsrc/components/ui/Button.tsxTests go here: src/components/ui/__tests__/Button.test.tsx
1. Rendering Tests
describe('Button', () => {
it('renders with default props', () => {
render(<Button>Click me</Button>)
expect(screen.getByText('Click me')).toBeInTheDocument()
})
it('renders with variant prop', () => {
render(<Button variant="primary">Button</Button>)
expect(screen.getByRole('button')).toHaveClass('variant-primary')
})
})
2. Interaction Tests
it('handles click events', () => {
const handleClick = jest.fn()
render(<Button onClick={handleClick}>Click</Button>)
fireEvent.click(screen.getByRole('button'))
expect(handleClick).toHaveBeenCalledTimes(1)
})
3. Props Variation Tests
it('renders disabled state', () => {
render(<Button disabled>Disabled</Button>)
expect(screen.getByRole('button')).toBeDisabled()
})
it('renders loading state', () => {
render(<Button loading>Loading</Button>)
expect(screen.getByText('Loading')).toBeInTheDocument()
})
4. Accessibility Tests
it('has proper aria attributes', () => {
render(<Button aria-label="Close dialog">×</Button>)
expect(screen.getByRole('button')).toHaveAttribute('aria-label')
})
5. Snapshot Tests
it('matches snapshot', () => {
const { container } = render(<Button>Button</Button>)
expect(container).toMatchSnapshot()
})
After creating tests:
# Test specific component
npm test -- --testPathPattern="Button"
# Check coverage for component
npm run test:coverage -- --testPathPattern="Button"
Expected: 80%+ coverage for that component
Each of the 24 pattern example components needs tests:
Pattern Demo Test Template
// src/components/examples/__tests__/[PatternName]Example.test.tsx
describe('[PatternName]Example', () => {
it('renders without crashing', () => {
render(<[PatternName]Example />)
expect(screen.getByTestId('[pattern-name]-demo')).toBeInTheDocument()
})
it('demonstrates the pattern correctly', () => {
render(<[PatternName]Example />)
// Test pattern-specific behaviors
// Verify interactive demo works
// Check all interactive elements
})
it('handles user interactions', () => {
render(<[PatternName]Example />)
// Test clicks, inputs, etc.
// Verify state changes
// Check visual updates
})
it('matches snapshot', () => {
const { container } = render(<[PatternName]Example />)
expect(container).toMatchSnapshot()
})
})
Your project has mocking infrastructure for:
// Mock Next.js components
jest.mock('next/image', () => ({
__esModule: true,
default: (props) => <img {...props} />
}))
// Mock framer-motion
jest.mock('framer-motion', () => ({
motion: { div: ({ children, ...props }) => <div {...props}>{children}</div> },
AnimatePresence: ({ children }) => children
}))
// Mock React hooks
jest.mock('react', () => ({
...jest.requireActual('react'),
useContext: jest.fn()
}))
| Category | Files | Coverage | Gap |
|---|---|---|---|
| UI Components | 12 | 65% | +5% |
| Example Components | 24 | 40% | +30% ⚠️ |
| Contexts | 3 | 55% | +15% |
| Hooks | 8 | 50% | +20% |
| Utilities | 15 | 45% | +25% |
| Data Validation | 5 | 83% | +0% ✅ |
Highest Impact: Example components (24 files at 40% = 30% gap opportunity)
npm run generate-all-tests
This command:
# Watch mode - auto-rerun on changes
npm run test:watch
# Test specific file
npm test -- Button.test.tsx
# Test specific pattern
npm test -- --testPathPattern="adaptive"
# Update snapshots (after intentional UI changes)
npm test -- -u
# List components without sufficient tests
npm run list-untested
# Generate tests for specific component
npm run generate-test
# Generate all missing tests
npm run generate-all-tests
# Run all tests with coverage
npm run test:coverage
# CI mode (used in deploy pipeline)
npm run test:ci
Track progress toward 70% goal:
When working on the 12 patterns requiring updates (via Pattern Development skill):
Goal: Reach 70% test coverage by systematically testing components with highest impact first, focusing on user interactions and behavior verification.