gen-test
星标10
分支8
更新时间2026年3月19日 13:38
Generate Vitest tests for a server action or component, following project conventions with Prisma mocks
安装
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
SKILL.md
readonly菜单
Generate Vitest tests for a server action or component, following project conventions with Prisma mocks
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Create a Prisma database migration: edit schema, run migrate dev, generate client, and verify types
Scaffold a new Server Action with auth, Zod validation, Prisma mutation, revalidation, and ActionResult types
Scaffold a new MUI component with Digital Playbook theme, proper client/server boundary, and project conventions
| name | gen-test |
| description | Generate Vitest tests for a server action or component, following project conventions with Prisma mocks |
| disable-model-invocation | true |
Generate Vitest tests following the project's existing patterns.
Accepts a file path or module name to generate tests for (e.g., /gen-test lib/actions/team.ts).
__tests__/ mirroring the source path (e.g., lib/actions/team.ts -> __tests__/lib/actions/team.test.ts)describe/it/expect from vitestvi.mock('@/lib/db/prisma')vi.mock('@/lib/auth/session')__tests__/ for pattern referencebun run test <path> to verify they passimport { describe, it, expect, vi, beforeEach } from 'vitest';
// Mock Prisma — replace <modelName> with actual model delegates
// used by the module under test (e.g., prisma.team, prisma.player)
vi.mock('@/lib/db/prisma', () => ({
prisma: {
// Example: mocking the 'team' model
team: {
findMany: vi.fn(),
findUnique: vi.fn(),
create: vi.fn(),
update: vi.fn(),
delete: vi.fn(),
},
// Add other model delegates as needed
},
}));
vi.mock('@/lib/auth/session', () => ({
requireUserId: vi.fn().mockResolvedValue('test-user-id'),
requireTeamAdmin: vi.fn().mockResolvedValue(undefined),
}));