界面已本地化;技能介绍与说明文档按所选语言由 AI 自动翻译,代码、命令、路径和专业术语保留原文,以原作者文档为准。
探索技能
开发与工程 · SKILL.md

snapshot-test

snapshot-test

【开发与工程】Generate Jest snapshot tests for components

独立 GitHub 快照 · 自动分类 · 以原作者文档为准

技能说明

GitHub

name: snapshot-test description: Generate Jest snapshot tests for components

Snapshot Test Generator

Point it at your components, get snapshot tests. Covers common states and props.

Quick Start

npx ai-snapshot-test ./src/components/Button.tsx

What It Does

  • Generates Jest snapshot tests
  • Covers default and edge cases
  • Tests different prop combinations
  • Handles async components

Usage Examples

# Generate for a component
npx ai-snapshot-test ./src/components/Card.tsx

# Generate for directory
npx ai-snapshot-test ./src/components/

# With specific test runner
npx ai-snapshot-test ./components --runner vitest

Output Example

describe('Button', () => {
  it('renders default state', () => {
    const { container } = render(<Button>Click me</Button>);
    expect(container).toMatchSnapshot();
  });

  it('renders disabled state', () => {
    const { container } = render(<Button disabled>Click me</Button>);
    expect(container).toMatchSnapshot();
  });
});

Test Cases Generated

  • Default props
  • Required prop variations
  • Edge cases (empty, null)
  • Loading/error states
  • Different sizes/variants

Requirements

Node.js 18+. OPENAI_API_KEY required.

License

MIT. Free forever.


Built by LXGIC Studios

我的收藏