This skill helps you write effective tests using Vitest and React Testing Library following project conventions.
Works with
AI-first code editor with Composer
Before installing skills in Cursor, ensure your development environment meets these requirements:
node --versionvitest-testing-patternsExecute the skills CLI command in your project's root directory to begin installation:
Fetches vitest-testing-patterns from erichowens/some_claude_skills and configures it for Cursor.
The CLI shows a list of agents. Use arrow keys and space to select Cursor:
Confirm successful installation by checking the skill directory location:
Restart Cursor to activate vitest-testing-patterns. Access via /vitest-testing-patterns in your agent's command palette.
We perform automated surface-level scans (Gen AI Scanner, Socket, Snyk) during installation. These checks detect common vulnerabilities but do not guarantee complete security. Always review skill source code and verify the publisher's reputation before production use.
Skills execute code in your environment. Always review source, verify the publisher, and test in isolation before production.
Submit your Claude Code skill and start earning
Automate repetitive workflows and reduce manual effort
Example
Generate reports, summarize documents, draft communications
Save 3-5 hours per week on routine tasks
Learn new skills, understand complex topics, get expert guidance
Example
Explain concepts, provide examples, suggest learning resources
Accelerate learning and skill development by 2x
Enhance output quality through reviews, suggestions, and refinements
Example
Review drafts, suggest improvements, catch errors
Improve work quality by 30-40% with less effort
0
total installs
0
this week
84
GitHub stars
0
upvotes
Run in your terminal
0
installs
0
this week
84
stars
This skill helps you write effective tests using Vitest and React Testing Library following project conventions.
✅ USE this skill for:
❌ DO NOT use for:
Configuration: vitest.config.ts
src/test/setup.tsCommands:
npm test # Watch mode
npm run test:run # Single run
npm run test:coverage # With coverage
src/
├── app/api/__tests__/ # API route tests
├── components/__tests__/ # Component tests
├── lib/__tests__/ # Library/utility tests
└── lib/{feature}/__tests__/ # Feature-specific tests
Name tests as {name}.test.ts or {name}.test.tsx.
import { describe, it, expect, vi, beforeEach } from 'vitest';
import { GET, POST } from '../route';
import { NextRequest } from 'next/server';
// Mock dependencies
vi.mock('@/lib/auth', () => ({
getSession: vi.fn(),
}));
vi.mock('@/db', () => ({
db: {
select: vi.fn().mockReturnThis(),
from: vi.fn().mockReturnThis(),
where: vi.fn().mockResolvedValue([]),
},
}));
describe('GET /api/feature', () => {
beforeEach(() => {
vi.clearAllMocks();
});
it('returns 401 when not authenticated', async () => {
vi.mocked(getSession).mockResolvedValue(null);
const request = new NextRequest('http://localhost/api/feature');
const response = await GET(request);
expect(response.status).toBe(401);
});
it('returns data when authenticated', async () => {
vi.mocked(getSession).mockResolvedValue({ userId: 'user-123' });
vi.mocked(db.select).mockReturnValue({
from: vi.fn().mockReturnValue({
where: vi.fn().mockResolvedValue([{ id: '1', name: 'Test' }]),
}),
});
const request = new NextRequest('http://localhost/api/feature');
const response = await GET(request);
const data = await response.json();
expect(response.status).toBe(200);
expect(data).toHaveLength(1);
});
});
import { describe, it, expect, vi } from 'vitest';
import { render, screen, waitFor } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import { FeatureComponent } from '../FeatureComponent';
// Mock hooks
vi.mock('@/hooks/useAuth', () => ({
useAuth: vi.fn().mockReturnValue({
user: { id: 'user-123', name: 'Test User' },
isLoading: false,
}),
}));
describe('FeatureComponent', () => {
it('renders loading state', () => {
vi.mocked(useAuth).mockReturnValueOnce({
user: null,
isLoading: true,
});
render(<FeatureComponent />);
expect(screen.getByText(/loading/i)).toBeInTheDocument();
});
it('handles user interaction', async () => {
const user = userEvent.setup();
const onSubmit = vi.fn();
render(<FeatureComponent onSubmit={onSubmit} />);
await user.type(screen.getByRole('textbox'), 'Test input')Prerequisites
Time Estimate
15-45 minutes depending on use case complexity
Steps
Common Pitfalls
✓ Do
✗ Don't
💡 Pro Tips
✓ Use when
Use when skill capabilities match your task, clear ROI on time saved, and you can validate outputs. Best for repetitive tasks, learning, and quality improvement.
✗ Avoid when
Avoid when task requires deep expertise you can't validate, involves sensitive decisions, or when learning process is more valuable than speed of completion.
erichowens/some_claude_skills
erichowens/some_claude_skills
github/awesome-copilot
aj-geddes/useful-ai-prompts
pproenca/dot-skills
refoundai/lenny-skills
I recommend vitest-testing-patterns for anyone iterating fast on agent tooling; clear intent and a small, reviewable surface area.
vitest-testing-patterns fits our agent workflows well — practical, well scoped, and easy to wire into existing repos.
Useful defaults in vitest-testing-patterns — fewer surprises than typical one-off scripts, and it plays nicely with `npx skills` flows.
Registry listing for vitest-testing-patterns matched our evaluation — installs cleanly and behaves as described in the markdown.
vitest-testing-patterns has been reliable in day-to-day use. Documentation quality is above average for community skills.
Useful defaults in vitest-testing-patterns — fewer surprises than typical one-off scripts, and it plays nicely with `npx skills` flows.
I recommend vitest-testing-patterns for anyone iterating fast on agent tooling; clear intent and a small, reviewable surface area.
vitest-testing-patterns reduced setup friction for our internal harness; good balance of opinion and flexibility.
vitest-testing-patterns is among the better-maintained entries we tried; worth keeping pinned for repeat workflows.
Registry listing for vitest-testing-patterns matched our evaluation — installs cleanly and behaves as described in the markdown.
showing 1-10 of 31