一键导入
typescript-testing
Applies Vitest test design and quality standards. Provides coverage requirements and mock usage guides. Use when writing unit tests.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Applies Vitest test design and quality standards. Provides coverage requirements and mock usage guides. Use when writing unit tests.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
PRD、ADR、Design Doc、UI Spec、作業計画書の作成を支援。技術ドキュメントの作成・レビュー時、または「UI Spec/画面設計/コンポーネント分解」が言及された時に使用。
入力・出力・成功基準・決定事項・未解決条件を明確化し、下流エージェントが推測せず実行できるようにする。LLM向けのプロンプト・ハンドオフ・計画成果物・レビュー・レポート・生成指示を記述または改訂する時に使用。
タスクの本質を分析し適切なスキルを選択。規模見積もりとメタデータを返却。タスク開始時、スキル選択時に使用。
Guides PRD, ADR, Design Doc, UI Spec, and Work Plan creation. Use when creating or reviewing technical documents, or when "UI spec/screen design/component decomposition" is mentioned.
Clarifies inputs, outputs, success criteria, decisions, and unresolved conditions so downstream agents can execute without guessing. Use when writing or revising LLM-facing prompts, handoffs, planning artifacts, reviews, reports, or generated instructions.
Analyzes task essence and selects appropriate skills. Returns scale estimates and metadata. Use when starting tasks or selecting skills.
| name | typescript-testing |
| description | Applies Vitest test design and quality standards. Provides coverage requirements and mock usage guides. Use when writing unit tests. |
import { describe, it, expect, beforeEach, vi } from 'vitest'vi.mock()Unit Tests
Integration Tests
Cross-functional Verification in E2E Tests
src/
└── application/
└── services/
├── __tests__/
│ ├── service.test.ts # Unit tests
│ └── service.int.test.ts # Integration tests
└── service.ts
{target-file-name}.test.ts{target-file-name}.int.test.tsRecommended: Keep all tests always active
Avoid: test.skip() or commenting out
Include boundary values and error cases alongside happy paths.
it('returns 0 for empty array', () => expect(calc([])).toBe(0))
it('throws on negative price', () => expect(() => calc([{price: -1}])).toThrow())
Use literal values for assertions. Do not replicate implementation logic. Valid test: Expected value != Mock return value (implementation transforms/processes data)
expect(calcTax(100)).toBe(10) // not: 100 * TAX_RATE
Verify results, not invocation order or count.
expect(mock).toHaveBeenCalledWith('a') // not: toHaveBeenNthCalledWith
Each test must include at least one verification.
it('creates user', async () => {
const user = await createUser({name: 'test'})
expect(user.id).toBeDefined()
})
Mock only direct external I/O dependencies. Use real implementations for indirect dependencies.
vi.mock('./database') // external I/O only
Use fast-check when verifying invariants or properties.
import fc from 'fast-check'
it('reverses twice equals original', () => {
fc.assert(fc.property(fc.array(fc.integer()), (arr) => {
return JSON.stringify(arr.reverse().reverse()) === JSON.stringify(arr)
}))
})
Usage condition: Use when Property annotations are assigned to ACs in Design Doc.
// Only required parts
type TestRepo = Pick<Repository, 'find' | 'save'>
const mock: TestRepo = { find: vi.fn(), save: vi.fn() }
// Only when absolutely necessary, with clear justification
const sdkMock = {
call: vi.fn()
} as unknown as ExternalSDK // Complex external SDK type structure
Mocks validate call patterns but cannot verify data layer correctness. The following pass through undetected with mock-only testing:
Options for verifying data layer correctness against a real database engine:
The appropriate approach depends on project environment and CI/CD capabilities.
import { describe, it, expect, vi } from 'vitest'
vi.mock('./userService', () => ({
getUserById: vi.fn(),
updateUser: vi.fn()
}))
describe('ComponentName', () => {
it('should follow AAA pattern', () => {
const input = 'test'
const result = someFunction(input)
expect(result).toBe('expected')
})
})