← Back to list

vitest-feature-protector
by mahmoudfarahat2647
⭐ 0🍴 0📅 Jan 24, 2026
SKILL.md
name: vitest-feature-protector description: Generate Vitest unit tests for new features/components to prevent regressions
Vitest Feature Protector
Automatically creates Vitest test templates when new features or components are added.
When to use this skill
- A new React/Vue component is created
- A new feature module is added
- Existing code needs test coverage
- User explicitly asks to "generate tests" or "create unit tests"
How to use it
-
Identify the target
- Get the feature/component name and file path
- Determine type: component, utility function, or feature logic
-
Generate test template
// For React components
import { describe, it, expect } from 'vitest'
import { render, screen } from '@testing-library/react'
import { ComponentName } from './ComponentName'
describe('ComponentName', () => {
it('should render without errors', () => {
render(<ComponentName />)
expect(screen.getByRole('...').toBeInTheDocument()
})
it('should handle props correctly', () => {
// TODO: Test props
})
})
-
File placement
- Components →
tests/components/ComponentName.test.tsx - Features →
tests/features/FeatureName.test.ts - Utils →
tests/utils/UtilName.test.ts
- Components →
-
Follow conventions
- Use
describe()for grouping - Use
it('should...')for test cases - Include at least: render test, props test, interaction test
- Add TODO comments for edge cases
- Use
-
Remind user to
- Run
npm testbefore committing - Check test coverage with
npm run test:coverage
- Run
Examples
User request: "Create a Button component"
Agent response:
// src/components/Button.tsx
export function Button({ label, onClick }) { ... }
// tests/components/Button.test.tsx
import { describe, it, expect, vi } from 'vitest'
import { render, screen, fireEvent } from '@testing-library/react'
import { Button } from '@/components/Button'
describe('Button', () => {
it('should render with label', () => {
render(<Button label="Click me" onClick={() => {}} />)
expect(screen.getByText('Click me')).toBeInTheDocument()
})
it('should call onClick when clicked', () => {
const handleClick = vi.fn()
render(<Button label="Click" onClick={handleClick} />)
fireEvent.click(screen.getByText('Click'))
expect(handleClick).toHaveBeenCalledOnce()
})
})
Notes
- Don't generate tests for third-party libraries
- Skip tests if user explicitly says "no tests needed"
- Prefer Testing Library queries in this order:
getByRole>getByLabelText>getByText
Score
Total Score
50/100
Based on repository quality metrics
✓SKILL.md
SKILL.mdファイルが含まれている
+20
○LICENSE
ライセンスが設定されている
0/10
○説明文
100文字以上の説明がある
0/10
○人気
GitHub Stars 100以上
0/15
○最近の活動
3ヶ月以内に更新がある
0/10
○フォーク
10回以上フォークされている
0/5
✓Issue管理
オープンIssueが50未満
+5
✓言語
プログラミング言語が設定されている
+5
○タグ
1つ以上のタグが設定されている
0/5
Reviews
💬
Reviews coming soon