/react-19:testing-componentsfrom react-19
Teaches React Testing Library patterns for React 19 components. Use when writing component tests, testing interactions, or testing with Server Actions.
Ships in react-19. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
For Vitest test structure and mocking patterns (describe/test blocks, vi.fn(), assertions), see vitest-4/skills/writing-vitest-tests/SKILL.md.
import { render, screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import Button from './Button';
test('button renders and handles click', async () => {
const handleClick = vi.fn();
render(<Button onClick={handleClick}>Click me</Button>);
const button = screen.getByRole('button', { name: /click me/i });
expect(button).toBeInTheDocument();
await userEvent.click(button);
expect(handleClick).toHaveBeenCalledTimes(1);
});
import { render, screen, waitFor } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import ContactForm from './ContactForm';
vi.mock('./actions', () => ({
submitContact: vi.fn(async (prev, formData) => {
const email = formData.get('email');
if (!email?.includes('@')) {
return { error: 'Invalid email' };
}
return { success: true };
}),
}));
test('form shows error for invalid email', async () => {
render(<ContactForm />);
await userEvent.type(screen.getByLabelText(/email/i), 'invalid');
await userEvent.click(screen.getByRole('button', { name: /submit/i }));
await waitFor(() => {
expect(screen.getByText(/invalid email/i)).toBeInTheDocument();
});
});
test('form succeeds with valid email', async () => {
render(<ContactForm />);
await userEvent.type(screen.getByLabelText(/email/i), '[email protected]');
await userEvent.click(screen.getByRole('button', { name: /submit/i }));
await waitFor(() => {
expect(screen.getByText(/success/i)).toBeInTheDocument();
});
});
import { render, screen } from '@testing-library/react';
import { UserProvider } from './UserContext';
import UserProfile from './UserProfile';
test('displays user name from context', () => {
const user = { name: 'Alice', email: '[email protected]' };
render(
<UserProvider value={user}>
<UserProfile />
</UserProvider>
);
expect(screen.getByText('Alice')).toBeInTheDocument();
});
For comprehensive testing patterns, see: React Testing Library documentation.
What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub djankies/claude-configs --plugin react-1926 skills in this plugin
/composing-componentsTeaches component composition patterns in React 19 including children prop, compound components, and render props. Use when designing component APIs, creating reusable components, or avoiding prop drilling./following-the-rules-of-hooksFix React Rules of Hooks violations - conditional calls, hooks in loops/callbacks/classes/implementing-code-splittingTeaches code splitting with lazy() and Suspense in React 19 for reducing initial bundle size. Use when implementing lazy loading, route-based splitting, or optimizing performance.Other plugins' skills for the same job