xiaohongshu
xiaohongshu
jest-test-scaffolder
Scaffolds Jest unit tests for React components and hooks. Use when creating tests for frontend components.
Full skill instructions
This skill creates comprehensive unit tests for React components using Jest, React Testing Library, and user-event.
Identify component to test:
src/components/ui/Button/Button.tsx){{COMPONENT_DIR}}/__tests__/{{COMPONENT_NAME}}.test.tsxAnalyze component structure:
Generate test file:
.claude/skills/jest-test-scaffolder/templates/component.test.tsx.tpl{{COMPONENT_NAME}} - Component name (PascalCase){{COMPONENT_PATH}} - Relative import path{{COMPONENT_ROLE}} - Accessibility role (button, textbox, etc.){{DEFAULT_PROPS}} - Default props for rendering{{EVENT_HANDLERS}} - Event handler tests{{STATE_TESTS}} - State variation tests (disabled, loading, etc.){{COMPONENT_DIR}}/__tests__/{{COMPONENT_NAME}}.test.tsxInclude comprehensive test scenarios:
Use React Testing Library best practices:
screen queries (getByRole, getByText, getByLabelText)userEvent for realistic interactionsjest.fn() for Jest mocksReport success:
yarn test {{COMPONENT_NAME}}When testing custom React hooks:
.claude/skills/jest-test-scaffolder/templates/hook.test.tsx.tpl@testing-library/react renderHook:
import { renderHook, act } from "@testing-library/react";
import { useCustomHook } from "./useCustomHook";
act()import { render, screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import { jest } from '@jest/globals';
import { {{COMPONENT_NAME}} } from './{{COMPONENT_NAME}}';
describe('{{COMPONENT_NAME}}', () => {
it('renders without errors', () => {
render(<{{COMPONENT_NAME}} {{DEFAULT_PROPS}} />);
expect(screen.getByRole('{{ROLE}}')).toBeInTheDocument();
});
it('handles user interactions', async () => {
const user = userEvent.setup();
const mock{{HANDLER}} = jest.fn();
render(<{{COMPONENT_NAME}} on{{HANDLER}}={mock{{HANDLER}}} />);
await user.click(screen.getByRole('{{ROLE}}'));
expect(mock{{HANDLER}}).toHaveBeenCalledTimes(1);
});
it('handles disabled state', async () => {
const user = userEvent.setup();
const mockHandler = jest.fn();
render(<{{COMPONENT_NAME}} disabled on{{HANDLER}}={mockHandler} />);
const element = screen.getByRole('{{ROLE}}');
expect(element).toBeDisabled();
await user.click(element);
expect(mockHandler).not.toHaveBeenCalled();
});
// TODO: Add accessibility tests
// TODO: Add snapshot tests
// TODO: Add edge case tests (empty props, long text, null values)
});
User: "Create tests for the Button component"
Claude (using jest-test-scaffolder):
1. Reads src/components/ui/Button/Button.tsx
2. Extracts props: { children, onClick, disabled, variant, size }
3. Generates src/components/ui/Button/__tests__/Button.test.tsx
4. Creates 5 test cases:
- Renders with correct text
- Calls onClick handler when clicked
- Is disabled when disabled prop is true
- Renders correct variant styles (TODO)
- Handles different sizes (TODO)
Files created:
- src/components/ui/Button/__tests__/Button.test.tsx (42 lines, 3 complete tests, 2 TODO tests)
Run tests:
yarn test Button
Test coverage:
✅ Render test
✅ Click interaction test
✅ Disabled state test
⚠️ Variant test (TODO)
⚠️ Size test (TODO)
This skill follows the existing test pattern from:
src/components/ui/Button/__tests__/Button.test.tsx (36 lines, 3 tests)describe and it blocksscreen.getByRole for queriesuserEvent.setup() and await user.click()jest.fn() for Jest mocksTest user behavior, not implementation:
Use userEvent over fireEvent:
Keep tests simple and focused:
Test accessibility:
Mock external dependencies:
This skill uses Jest (not Vitest):
jest.fn() instead of vi.fn()jest.mock() instead of vi.mock()jest.spyOn() instead of vi.spyOn()webapp-testing skill (Playwright)api-integration-test-scaffolderpytest-test-scaffolderstorybook-scaffolderxiaohongshu
technical spec
product ux expert
database patterns
Conduct multi-agent task orchestration and workflow coordination.
Initialize project with Conductor artifacts (product definition,
Expert in web animations, transitions, and motion design using Framer Motion and CSS
Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...
PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.
Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...
Display project status, active tracks, and next actions
Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.
Generate, edit, and beat-sync AI video with leading models in one workspace.
The world's fastest calendar for remote work
Transform Your Design with AI Designer by ImgCreator.ai
Revolutionizing Video Production with AI-Powered Creativity
Extend an image past the frame and let AI fill the new aspect ratio.
Discover your celebrity doppelgänger with StarByFace!
ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.
Opus.ai: Revolutionize Your Web Experience