スキル一覧に戻る
SammySnake-d

testing

by SammySnake-d

0🍴 0📅 2026年1月4日
GitHubで見るManusで実行

SKILL.md


name: testing description: 测试规范与最佳实践。Use when writing unit tests, integration tests, or component tests. Triggers on: creating test files, using Vitest, Testing Library, mocking, test organization questions.

Testing Guide

测试规范,涵盖 Vitest、Testing Library 和测试组织。

Quick Start

import { describe, it, expect } from 'vitest';

describe('ModuleName', () => {
  it('should behavior description', () => {
    expect(actual).toBe(expected);
  });
});

Test Location

All tests in __tests__/ directory, mirroring source structure:

__tests__/
├── lib/utils/
├── lib/services/
├── components/
└── hooks/

File Naming

  • Unit tests: *.test.ts / *.test.tsx
  • Integration tests: *.spec.ts / *.spec.tsx

Commands

pnpm test           # Run all tests
pnpm test:watch     # Watch mode
pnpm test:coverage  # Coverage report

Component Test

import { render, screen } from '@testing-library/react';
import { Button } from '@/components/ui/button';

describe('Button', () => {
  it('should render children', () => {
    render(<Button>Click</Button>);
    expect(screen.getByText('Click')).toBeInTheDocument();
  });
});

Mocking

import { vi } from 'vitest';

vi.mock('@/lib/services', () => ({
  UserService: {
    getUser: vi.fn().mockResolvedValue({ id: '1' }),
  },
}));

Coverage Requirements

  1. Normal path - Expected behavior
  2. Edge cases - Empty, null, boundary values
  3. Error handling - Exception scenarios

スコア

総合スコア

50/100

リポジトリの品質指標に基づく評価

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

レビュー

💬

レビュー機能は近日公開予定です