用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/tomevault-io/skills-registry --skill regression-test-generator命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
正在显示 SKILL.md
基于 SOC 职业分类
| name | regression-test-generator |
| description | > Use when this capability is needed. |
Generate a targeted regression test for a verified fix — auto-detect conventions, route to the correct test framework, annotate coverage boundaries.
__tests__/ or root tests/ directory)vitest, jest, playwright) — no other shell commandsaffectedFiles, diff, diagnosis_ref, notAddressedrootCause and issueClassification.. or shell metacharacters.vitest, jest, playwright) with the generated test file path. No user-provided strings are interpolated into commands.Copy this checklist and update as you complete each step:
Progress:
- [ ] Step 1: Read the FixResult
- [ ] Step 2: Classify Component Type
- [ ] Step 3: Detect Project Conventions
- [ ] Step 4: Generate the Test
- [ ] Step 5: Place the Test File
- [ ] Step 6: Validate the Test
Note: If you've lost context of previous steps (e.g., after context compaction), check the progress checklist above. Resume from the last unchecked item. Re-read relevant reference files if needed.
Extract from the upstream FixResult:
affectedFiles — the files that were changeddiff — what changed (the fix)diagnosis_ref — the original bug descriptionnotAddressed — related issues not covered by the fixDetermine the routing target. This is a hard rule:
| Component type | Detected by | Route to |
|---|---|---|
| Sync client component | "use client" directive, uses hooks, event handlers | Vitest + RTL |
| Sync server component | No "use client", no hooks, no async | Vitest + RTL |
| Async server component | async function Component(), await in body, fetch() / cookies() / headers() | Playwright E2E |
| Mixed (client wrapper around async server) | Both patterns present | Playwright E2E for the page, Vitest+RTL for the client wrapper |
If async server component → read references/playwright-patterns.md.
Otherwise → read references/vitest-rtl-patterns.md.
Scan for existing test files near the affected component:
**/*.test.{ts,tsx}, **/*.spec.{ts,tsx}, **/__tests__/** in the same package@testing-library/react vs custom test-utils wrapperrender() vs custom render with providersgetByRole vs getByTestId vs getByText__tests__/ or .test.tsx next to component) vs root tests/ dirComponentName.test.tsx vs component-name.spec.tsx.test.tsx naming.Write the test file following detected conventions. Every generated test must include:
Header annotations (mandatory):
/**
* Regression test for: [bug title from DiagnosisReport]
* Bug: [1-sentence defect description]
* Fix: [1-sentence fix description]
*
* GUARDS AGAINST: [specific scenario this test catches]
* DOES NOT GUARD AGAINST: [related untested scenarios from notAddressed]
*/
Test structure:
describe('[ComponentName] - regression: [bug-slug]', () => {
it('should [expected behavior that was broken]', () => {
// Arrange: conditions that triggered the bug
// Act: user action that exposed the bug
// Assert: correct behavior
});
});
Anti-brittleness rules (hard constraints):
getByRole with accessible name: getByRole('button', { name: /submit/i })screen object, not destructured render returnsquerySelector('.a > .b'))Follow the convention detected in Step 3:
tests/ pattern: mirror the source directory structure.test.tsx vs .spec.tsx)Show the full file path and contents. Pause: "Write this test file?"
After writing the test file, run it once:
# Vitest
npx vitest --run --reporter=verbose <test-file>
# Jest
npx jest <test-file> --verbose
# Playwright
npx playwright test <test-file> --reporter=list
Report result:
RegressionTest:
version: "1.0"
fix_ref: "[FixResult ID]"
testFile: "path/to/ComponentName.test.tsx"
framework: "vitest-rtl | jest-rtl | playwright"
guardsAgainst: "specific regression scenario"
doesNotGuardAgainst: ["untested scenario 1", "untested scenario 2"]
conventions:
source: "detected | defaults"
nearestTestFile: "path or null"
result: { status: "pass | fail", error: "message or null" }
Pass the RegressionTest artifact path to qa-coordinator. The result contains testFile, framework, guardsAgainst, and doesNotGuardAgainst fields. This is the final phase of the QA pipeline.
| Path | Load Condition | Content Summary |
|---|---|---|
references/vitest-rtl-patterns.md | Step 2, sync client or server component | Query priority, rendering patterns, assertion patterns, anti-patterns |
references/playwright-patterns.md | Step 2, async server component or mixed | Test structure, locator priority, common regression patterns, API mocking |
Converted and distributed by TomeVault — claim your Tome and manage your conversions.