test-helpers
Skill41 starsChanged 7 months agoMITView on GitHub
Generates a framework-specific test helper library — factories, mocks, custom matchers, and shared assertion utilities — under tests/helpers/. Reduces boilerplate in new test files. Run after /test-setup once the project has a few real tests.
4 other projects use a version of this.
Adopted by
Most recently taken up by
- HunLuanZhiZhu/Game-Studios-Plugintheir own version, first seen Oct 5, 2026
- Donchitos/Claude-Code-Game-Studiostheir own version, first seen Sep 29, 2026
- dawn840705/codex-code-studiostheir own version, first seen Aug 28, 2026
- striderZA/OpenCodeGameStudiostheir own version, first seen Aug 10, 2026
Other versions4 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 4
- Donchitos/Claude-Code-Game-Studios★ 26ksame name
- striderZA/OpenCodeGameStudios★ 90same name
- dawn840705/codex-code-studios★ 17same name
- HunLuanZhiZhu/Game-Studios-Plugin★ 1same 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 repository77 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- design/CLAUDE.mdCLAUDE.md
- docs/CLAUDE.mdCLAUDE.md
- src/CLAUDE.mdCLAUDE.md
- tests/CLAUDE.mdCLAUDE.md
- adoptSkill
- architecture-decisionSkill
- architecture-reviewSkill
- asset-auditSkill
- asset-specSkill
- balance-checkSkill
- brainstormSkill
- bug-reportSkill
- bug-triageSkill
- changelogSkill
- code-reviewSkill
- consistency-checkSkill
- content-auditSkill
- create-architectureSkill
- create-control-manifestSkill
- create-epicsSkill
- create-storiesSkill
- day-one-patchSkill
- design-bibleSkill
- design-reviewSkill
- design-systemSkill
- dev-storySkill
- estimateSkill
- extractSkill
- gate-checkSkill
- helpSkill
- hotfixSkill
- launch-checklistSkill
- localizeSkill
- map-systemsSkill
- milestone-reviewSkill
- onboardSkill
- patch-notesSkill
- perf-profileSkill
- prd-reviewSkill
- project-stage-detectSkill
- propagate-design-changeSkill
- prototypeSkill
- qa-planSkill
- quick-designSkill
- regression-suiteSkill
- release-checklistSkill
- retrospectiveSkill
- reverse-documentSkill
- review-all-prdsSkill
- scope-checkSkill
- security-auditSkill
- setup-frameworkSkill
- skill-improveSkill
- skill-testSkill
- smoke-checkSkill
- soak-testSkill
- sprint-planSkill
- sprint-statusSkill
- startSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
5 rules. 0 are common, 2 are distinctive, and 3 are very specific to this project.
0
Common
Most of the 4 edited versions we read keep these.
2
Distinctive
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 65
Use AskUserQuestion to confirm:
- Very specific: line 75
Create files under tests/helpers/ grouped by purpose.
- Very specific: line 136
Create tests/helpers/README.md with one short section per helper:
- Distinctive: line 143
Keep entries terse — engineers will skim, not read.
- Very specific: line 185
Run /test-evidence-review after the next sprint to verify the helpers are actually being used.
“Common” is measured: kept by at least 6 in 10 of the 4 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 Helpers
Reads existing tests, finds repeated setup, and extracts that into a helper library so future tests stay short and intention-revealing.
Phase 1: Read Project Context
Read in parallel:
.claude/docs/technical-preferences.md— Framework, Testing Framework, Naming Conventions..claude/docs/coding-standards.md— test rules.tests/helpers/(if present) — what already exists.
Confirm the framework. If unset, redirect to /setup-framework.
Phase 2: Scan Existing Tests
Glob the test tree:
- RN/TS:
tests/**/*.test.{ts,tsx,js,jsx} - Flutter:
tests/**/*_test.dartandtest/**/*_test.dart - iOS:
tests/**/*Tests.swift - Android:
tests/**/*Test.kt
For each file, find:
- Repeated factory functions (e.g., builders that return a
User,Product,CartItem, etc.). - Repeated mocks (network client, storage, analytics, deep-link router, push handler).
- Repeated assertion patterns (e.g., "the screen shows error X" or "the store dispatched action Y").
- Repeated setup/teardown blocks (auth state, seed data, navigation stack).
Group results by recurrence count. Anything that appears 3+ times is a candidate.
Phase 3: Propose the Helper API
Produce a proposal table:
| Helper | Type | Used in | Reason |
makeUser({...overrides}) | Factory | 8 tests | duplicated user objects |
mockApiClient(responses) | Mock | 5 tests | repeated fetch stubs |
expectScreenShowsError(matcher) | Matcher | 4 tests | repeated assertion |
Use AskUserQuestion to confirm:
[A] Generate every helper in the table[B] Generate only the top N[C] Let me pick — show one at a time
Phase 4: Write the Helpers
Create files under tests/helpers/ grouped by purpose. Always ask before
each write. Naming follows the framework convention.
Factories — tests/helpers/factories/*
Pattern: pure functions that take an overrides object and return a
fully-formed domain object with sensible defaults.
// React Native example
export const makeUser = (overrides: Partial<User> = {}): User => ({
id: 'user-1',
email: 'a@b.com',
isVerified: true,
...overrides,
});Mocks — tests/helpers/mocks/*
Pattern: factory functions that return an interface-shaped mock object. For each platform module the project commonly stubs (network, storage, analytics, biometrics, push, location), provide a mock factory.
Custom matchers — tests/helpers/matchers/*
Wrap repeated assertions in named matchers with clear failure messages. Examples:
toHaveDispatched(action)for a Redux store.toRenderError(message)for a screen-level error UI.toMatchSnapshotIgnoring([fields])for resilient snapshot tests.
Test fixtures — tests/helpers/fixtures/*
For canned responses (paginated lists, deep-link payloads, push payloads), provide JSON fixtures plus a small loader utility.
Render helpers — tests/helpers/render.{ts,dart,swift,kt}
Wrap the framework's render call to also wire navigation, theme, store, and i18n providers in one call:
- RN:
renderWithProviders(ui, { store, navState }) - Flutter:
pumpWithProviders(tester, widget, { router, theme }) - SwiftUI:
RenderHost(view).withStubbedDeps() - Compose:
composeTestRule.setContentWithProviders { ui }
Phase 5: Refactor One Existing Test as a Demo
Pick the highest-duplication file from Phase 2. Refactor it to use the new helpers. Show the diff and ask the user to approve before saving.
This proves the helpers work and provides a reference for future authors.
Phase 6: Document the Helpers
Create tests/helpers/README.md with one short section per helper:
- Signature
- One-line purpose
- One-line usage example
- The original-pattern problem it replaces
Keep entries terse — engineers will skim, not read.
Phase 7: Update Coding Standards
Append a Test Helpers block to .claude/docs/coding-standards.md:
- Where helpers live.
- The rule: "Before adding a third copy of any test setup, extract it
into
tests/helpers/." - The rule: "New tests must use existing helpers when applicable."
Confirm before writing.
Quality Gates / PASS-FAIL
- PASS — every generated helper compiles; the demo refactored test still passes; README exists; standards updated.
- FAIL — any helper has a type error or runtime error in the smoke run. Roll back the failing helper and surface the diagnostic.
Examples
Example 1 — RN app with 14 tests:
Detects that 9 tests build a Product object inline. Generates
makeProduct, refactors tests/unit/cart/cartReducer.test.ts to use it,
adds a README entry, and updates standards.
Example 2 — Flutter app:
Detects a pumpWithRouter pattern repeated across widget tests.
Extracts tests/helpers/pump.dart and refactors one widget test as the
canonical example.
Next Steps
- Run
/test-evidence-reviewafter the next sprint to verify the helpers are actually being used. - Re-run
/test-helpers --scanperiodically (start of each sprint) to catch new duplication early.
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.

