test-gen
Skill0 starsChanged 6 months agoMITView on GitHub
Generate frontend tests by deciding which parts belong in unit tests and which belong in end-to-end (e2e) tests, then writing runnable test code that matches the project's existing stack. Framework-agnostic: works with Vue or React, Vitest or Jest, Playwright or Cypress, with or without MSW. 生成前端测试:把要测的内容拆开,判定哪些写单测、哪些写 e2e,再按项目现有技术栈产出可直接运行的测试代码。框架无关,自动适配项目已有的 runner 与组件框架。 Use this skill whenever the user wants to: - "/test-gen", "生成测试", "写测试 / 写单测 / 写 e2e", "补测试", "add tests", "write tests for this", "how should I test this" - paste a feature description, requirement, user flow, test case, or source file and ask for tests - ask "should this be a unit test or e2e", "帮我拆一下测试", split testing responsibilities Trigger even when the user does not explicitly say "unit" or "e2e" — any request to add automated verification for frontend behavior should use this skill.
10 other projects use a version of this.
Adopted by
Most recently taken up by
- AllThingsSmitty/proven-skillstheir own version, first seen Oct 6, 2026
- SethGammon/Citadeltheir own version, first seen Sep 20, 2026
- Pradnyeshp/Claude-Skillstheir own version, first seen Jul 6, 2026
- EvildoerXiaoyy/reasonix-skillstheir own version, first seen Jun 23, 2026
- thijsvos/Claude_Skillstheir own version, first seen May 14, 2026
- ilhankilic/yaratai-skilltheir own version, first seen Apr 14, 2026
Used with
Projects with it also use refactor and review.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
GitHubSkillrefactor
Surgical code refactoring to improve maintainability without changing behavior. Covers extracting functions, renaming variables, breaking down god functions, improving type safety, eliminating code smells, and applying design patterns. Less drastic than repo-rebuilder; use for gradual improvements.
Also in 5 projects that use this
SentrySkillreview
Fixture review skill.
Also in 3 projects that use this
Other versions10 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 10
- SethGammon/Citadel★ 922same name
- EvildoerXiaoyy/reasonix-skills★ 4same name
- kronus-tech/kronus★ 4same name
- chidekina/aria-superpowers★ 2same name
- liogogogo/claude-code-enhancement★ 2same name
- Pradnyeshp/Claude-Skills★ 2same name
- AllThingsSmitty/proven-skills★ 1same name
- ilhankilic/yaratai-skill★ 1same name
- thijsvos/Claude_Skills★ 1same name
- 354685856-sn/claude-code-skills★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repositoryOne other file it gives its agents.
- test-setupSkill
The file
We split this skill into the rules it gives an agent
6 rules. 0 are common, 5 are distinctive, and 1 is very specific to this project.
0
Common
Most of the 6 edited versions we read keep these.
5
Distinctive
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 25
Never assume the stack. Launch read-only subagents in parallel to determine:
- Very specific: line 33
If the project has no test setup at all, tell the user to run /test-setup first, then come back.
- Distinctive: line 91
Run the unit tests for the affected package.
- Distinctive: line 92
Run the e2e tests (install browsers first if needed).
- Distinctive: line 93
If red: first suspect an assertion locked to "ideal spec" instead of current behavior, or an unmocked request (strict mock modes fail …
- Distinctive: line 101
Write e2e in "human language": test names describe user-visible behavior.
“Common” is measured: kept by at least 6 in 10 of the 6 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
test-gen
Translate "what needs to be verified" into "which kind of test + runnable code". Two jobs: decide unit vs e2e, and write tests that match the project's existing conventions.
One sentence behind every decision: unit tests guard the parts, e2e guards that the assembled whole actually works. Most frontend bugs are not "computed wrong" but "wired wrong" — data flows from an API through a store, through derived state, down to some component's class, and any broken assumption in that chain passes every unit test while the page breaks on click. e2e covers exactly that. This matters even more for AI-written code, whose understanding is local and which most easily produces "every part green, assembled it crashes".
Workflow
This skill expects parallel execution across multiple contexts. Detection, generation, and self-check are independent kinds of work — fan them out with subagents instead of doing everything serially. Each step notes what to parallelize.
Step 0 · Detect the project's test stack (parallelizable)
Never assume the stack. Launch read-only subagents in parallel to determine:
- Component framework: Vue 3 / React / other (check
package.jsondeps, file extensions). - Unit runner: Vitest / Jest (config files, scripts). Env: jsdom / happy-dom / node.
- e2e runner: Playwright / Cypress (config,
e2e/orcypress/dirs). - Network mocking: MSW present? a shared fixtures/mock package? Or per-test mocks?
- Reusable assets: existing test helpers, fixtures,
e2e/helpers.*, mount helpers, naming conventions, where tests live.
If the project has no test setup at all, tell the user to run /test-setup first, then come back.
Record the detected stack — every generated file must match it. The decision framework is universal; only the syntax of the generated code depends on the stack.
Step 1 · Parse input into verifiable units
Input may be a plain-language test case, a requirement, a component/function file, or a user flow. Break it into the smallest verifiable points — each answering "given this input/precondition, what observable result is expected".
Separate two kinds:
- Part-level: pure functions I/O, store actions/getters, composable/hook state transitions, a single component's render/events given props.
- Assembly-level: behavior crossing store → derived state → multiple components → API → render; failure/edge/retry/limit paths; streaming render, overlay enter/exit, real interaction timing.
Step 2 · Decide unit vs e2e
Classify each verifiable point with the framework below. If you cannot decide confidently, do not guess — go to Step 3 and ask. Read references/decision-framework.md for full rules, signals, and worked examples before concluding.
Quick reference:
| Signal | Leans | Why |
| Pure logic, computation, data transform | Unit | A part; deterministic I/O; fastest, most stable |
| Store action/getter, composable/hook state | Unit | Call directly or mount in isolation |
| Single component render/events/branches given props | Unit | Isolated component test |
| A user "clicks through" flow across components/store/API | e2e | Assembled whole; catches the "wired wrong" units miss |
| Failure, timeout, retry, limit, stream interruption | e2e | Network-layer mock reproduces deterministically |
| Overlay enter/exit, streaming render, real interaction timing | e2e | Closest to a real user, hardest to fool |
| Heavy third-party DOM/canvas/rich-text integration | Consider excluding | Low cost/benefit to hard-test; exclude from coverage |
Most features need both: parts covered by unit tests, key flows and failure paths locked by e2e. Tell the user how each point was classified and why.
Step 3 · Ask when unclear (use structured questions)
Whenever an uncertainty would affect test correctness, stop and ask rather than hallucinating an assertion. Typical cases:
- The real current behavior is unclear (assert current state vs ideal spec — see Principles).
- The API shape/fields/response is unknown and no fixture exists.
- The precondition to reach the target UI is unclear (auth, seeded data, a dev/debug entry).
- Failure/edge-path copy or UI is uncertain.
- Whether the feature is "not worth hard-testing / exclude from coverage" is unclear.
Offer concrete options with a recommendation. Record the resolution in the final report.
Step 4 · Generate test code in parallel (multiple contexts)
Once classified, fan out generation by independent artifact (use generalPurpose subagents), e.g.:
- Subagent A: unit tests for the module (in the project's unit-test location).
- Subagent B: e2e specs + any needed helpers.
- Subagent C: shared fixtures / mocks (all mock data lives in one shared source, reused by unit and e2e — never fork a second copy inside the app).
Each subagent's brief must include: the detected stack, the relevant references/conventions-*.md, the reusable assets found in Step 0, and the "assert current real behavior" principle. Follow references/conventions-unit.md, references/conventions-e2e.md, and references/mocking.md for syntax.
If artifacts depend on each other (e.g. an e2e spec needs a new fixture), produce fixtures first, then specs. Fan out everything independent in the same batch.
Step 5 · Self-check and run
Back in the main context:
- Run the unit tests for the affected package.
- Run the e2e tests (install browsers first if needed).
- If red: first suspect an assertion locked to "ideal spec" instead of current behavior, or an unmocked request (strict mock modes fail loudly on purpose).
- Lint the new files and fix issues.
Core principles (pass these to every subagent)
- Assert "current real behavior", not "ideal product spec". A test's first job is regression protection — catching "I broke it by accident". If code reality differs from the product's intended spec, assert reality and add a comment: "if product changes to X, update here". Asserting the ideal spec makes the test red from day one; red-until-numb means a dead test.
- Single source of mock data: fixtures live in one shared place, reused by unit and e2e. Change the API contract in one spot.
- Unmocked requests should fail loudly (e.g. MSW
onUnhandledRequest: 'error'; e2e intercept at the network layer). A silently-passing test that hit a real backend is worse than no test. - Write e2e in "human language": test names describe user-visible behavior; extract repeated steps into helpers.
- Prioritize failure and edge paths — this is where e2e shines and manual testing can't give determinism.
Output report
## Test generation report
### Detected stack
- Framework / unit runner / e2e runner / mocking
### Breakdown & classification
| Verifiable point | Type | Target file | Reason |
|---|---|---|---|
### Files added/changed
- unit / e2e / fixtures
### Clarifications (if asked)
- Q / A
### How to run
- unit: ...
- e2e: ...
### Run result
- unit: X passed / e2e: X passed
### Reuse check
Checked <existing fixtures / helpers / tests>; reused ...; did not reuse because ...Reference files
references/decision-framework.md— Full unit-vs-e2e rules, signals, and worked examples. Read before concluding.references/conventions-unit.md— Unit/component test templates for Vitest & Jest (Vue & React).references/conventions-e2e.md— e2e templates for Playwright (and Cypress notes).references/mocking.md— The single-source-fixtures pattern: MSW (unit) + network interception (e2e) sharing one fixture set.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

