component-test
Skill2 starsChanged 8 months agoMITView on GitHub
Generate production-grade Vitest tests from HTML elements captured in DevTools. Two-phase workflow (analysis → generation) with edge case discovery.
2 other projects use a version of this.
Adopted by
Most recently taken up by
- microsoft/coreai-design-systemtheir own version, first seen Oct 17, 2026
- garthcodes/claude-skillstheir own version, first seen Oct 8, 2026
Other versions2 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 2
- garthcodes/claude-skills★ 2same name
- microsoft/coreai-design-system★ 2same 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 repository21 other files it gives its agents.
- vercel-react-best-practices/AGENTS.mdAGENTS.md
- audit-as-a11y-engSkill
- audit-as-backend-engSkill
- audit-as-design-engSkill
- audit-as-dx-engSkill
- audit-as-frontend-engSkill
- audit-as-perf-engSkill
- audit-as-prod-readinessSkill
- audit-as-repo-maintainerSkill
- audit-as-structural-engSkill
- audit-as-ux-engSkill
- blueprint-firstSkill
- fazxesSkill
- full-auditSkill
- mosaicSkill
- problem-clarifierSkill
- stress-testSkill
- test-engineerSkill
- uiSkill
- vercel-react-best-practicesSkill
- web-design-guidelinesSkill
The file
We split this skill into the rules it gives an agent
4 rules. About 0 are common, 2 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 35
Write test files based on approved plan, including edge case coverage.
- Distinctive: line 52
If multiple files match or no match found, request clarification.
- Very specific: line 56
Read the target file and its direct dependencies (custom hooks from src/, Zustand stores, contexts).
- Very specific: line 155
If flagged, output the specific file:line and suggest a concrete refactor.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Component Test Generator
Generate tests for React components, hooks, and contexts by analyzing source code. This skill locates targets, discovers edge cases, and produces production-grade Vitest tests.
Usage: /component-test then provide one of:
- HTML element from DevTools
- Hook name (e.g.,
useFileOperations) - Context name (e.g.,
ThemeContext) - File path (e.g.,
src/components/FileExplorer/index.tsx)
Technology Stack
- Testing: Vitest + React Testing Library
- State: Zustand for state management
- Backend: Tauri 2 for commands, events, and system APIs
- Types: TypeScript throughout
- Routing: React Router or TanStack Router (detect from imports)
- Possible: ReactFlow, dnd-kit, react-window, Framer Motion
Two-Phase Workflow
Phase 1: Analysis
Identify target, read code, classify, discover edge cases, plan tests. Output analysis and wait for user to reply "proceed".
Phase 2: Generation
Write test files based on approved plan, including edge case coverage.
Phase 1: Analysis Instructions
Step 1: Identify the Test Target
Determine what you're testing based on input:
| Input Type | Target Type | Search Strategy |
| HTML element | Component | data-testid → id → unique text |
| Hook name | Custom Hook | grep for export function use or export const use |
| Context name | Context/Provider | grep for createContext |
| File path | Direct | Read file directly |
If multiple files match or no match found, request clarification.
Step 2: Read and Quote Behavior Code
Read the target file and its direct dependencies (custom hooks from src/, Zustand stores, contexts).
Quote behavior-proving code based on target type:
| Target Type | Quote |
| Component | useState, useEffect, store selector, conditional render |
| Hook | Return value, internal state, effect dependencies |
| Context | Default value, Provider value computation |
| Provider | Children rendering, value memoization |
Skip third-party hooks and utility hooks (useDebounce, useLocalStorage).
Step 3: Discover Edge Cases
Read references/edge-case-patterns.md for comprehensive edge case lists by category.
Analyze the code for edge cases. Check all applicable categories:
Data Edge Cases:
- Empty arrays/objects, null, undefined
- Single item vs multiple items
- Maximum lengths, large datasets
- Special characters (unicode, spaces, path separators)
- Numeric boundaries (0, negative, MAX_SAFE_INTEGER, NaN)
- Invalid/malformed data from backend
State Edge Cases:
- Initial state before data loads
- Loading states and transitions
- Error states and recovery
- Rapid state changes (double-clicks, debounce)
- Stale state after unmount
Async Edge Cases:
- Network failures / Tauri command rejections
- Slow responses (loading indicators, timeouts)
- Out-of-order responses
- Retry logic
Interaction Edge Cases:
- Disabled states
- Keyboard navigation boundaries
- Repeated rapid interactions
- Interaction during loading
- Touch vs mouse (if applicable)
Accessibility Edge Cases:
- Focus management (trap, restore, initial)
- Screen reader announcements
- Keyboard-only navigation
- Reduced motion preferences
Router Edge Cases:
- Direct URL access (deep linking)
- Back/forward navigation
- Route params (missing, malformed)
- Protected route redirects
- Concurrent navigation
Drag and Drop Edge Cases:
- Drop on invalid target
- Cancel mid-drag (Escape)
- Drag outside container
- Keyboard drag mode
Virtualization Edge Cases:
- Scroll to specific item
- Dynamic item heights
- Empty list, single item
- Rapid scrolling
Animation Edge Cases:
- Reduced motion preference
- Animation interrupt
- Unmount during animation
For each edge case found, note the relevant code line that handles it (or mark as unhandled).
Step 4: Check Testability
Flag for refactoring if:
- Component >400 lines WITH
useEffectcalling external APIs AND >5 return statements useEffectwith no dependency array that callssetState- Store action called in render body (outside handler/effect)
- Imports from >3 different Zustand stores
- Hook does both data fetching AND UI state management
- Context Provider has >200 lines of logic
If flagged, output the specific file:line and suggest a concrete refactor.
Step 5: Classify and Select Test Types
Target Classifications:
| Classification | Criteria |
| PRESENTATIONAL | No effects, no stores, no Tauri, props-only |
| STATEFUL-SIMPLE | Local state + effects, no Tauri/stores |
| STATEFUL-CONNECTED | Uses Zustand stores, Tauri, or subscriptions |
| CUSTOM-HOOK | Exported hook (not component) |
| CONTEXT-PROVIDER | createContext + Provider component |
| ROUTE-COMPONENT | Rendered by router, uses route params/navigation |
| VIRTUALIZED | Uses react-window, tanstack-virtual, or similar |
| DND-COMPONENT | Uses dnd-kit, react-beautiful-dnd, or similar |
| ANIMATED | Uses Framer Motion, react-spring, or CSS animations |
Test Type Selection:
| Classification | Default Tests | Add When |
| PRESENTATIONAL | UNIT | Add A11Y if interactive |
| STATEFUL-SIMPLE | UNIT | Add INTEGRATION for multi-step flows |
| STATEFUL-CONNECTED | INTEGRATION | Add UNIT for complex logic; TYPE SHAPE for Tauri |
| CUSTOM-HOOK | HOOK | Always |
| CONTEXT-PROVIDER | CONTEXT | Add INTEGRATION if Provider has side effects |
| ROUTE-COMPONENT | ROUTE | Add INTEGRATION for data loading |
| VIRTUALIZED | VIRTUALIZATION | Add INTEGRATION for data |
| DND-COMPONENT | DND | Add INTEGRATION for state updates |
| ANIMATED | ANIMATION | Add UNIT for non-animated logic |
Additional Test Types (add when applicable):
| Test Type | Add When |
| A11Y | Interactive elements, forms, modals, focus management |
| SNAPSHOT | Stable UI components, design system components |
| PERFORMANCE | Components with frequent re-renders, large lists |
| TAURI-SYSTEM | Uses dialog, fs, clipboard, shell, or window APIs |
Step 6: List Testable Behaviors
Format: [Trigger] → [Expected outcome] → [Pattern: sync/async/cleanup/error/a11y]
Organize into groups:
- Core Behaviors — Primary happy-path functionality
- Edge Cases — Boundary conditions by category
- Accessibility — Focus, ARIA, keyboard navigation
- Performance — Render counts, memoization (if applicable)
Mark edge cases with category: [EDGE: data], [EDGE: async], [EDGE: a11y], etc.
Fast Path: For PRESENTATIONAL components <50 lines with ≤3 conditional renders, skip detailed analysis.
Phase 2: Generate Tests
Read references/test-examples.md for code templates and mock patterns for all test types.
File Locations
| Test Type | Location |
| Unit | src/components/[path]/__tests__/[Name].unit.test.tsx |
| Integration | src/components/[path]/__tests__/[Name].test.tsx |
| Hook | src/hooks/__tests__/[hookName].test.ts |
| Context | src/contexts/__tests__/[Name].test.tsx |
| A11y | src/components/[path]/__tests__/[Name].a11y.test.tsx |
| Route | src/routes/__tests__/[Name].test.tsx |
| Type Shape | src/components/[path]/__tests__/[Name].types.test.tsx |
| Snapshot | src/components/[path]/__tests__/[Name].snapshot.test.tsx |
| Performance | src/components/[path]/__tests__/[Name].perf.test.tsx |
Test Organization
describe('TargetName', () => {
describe('core functionality', () => {
// happy path tests
});
describe('edge cases: [category]', () => {
// boundary tests
});
describe('accessibility', () => {
// a11y tests
});
describe('performance', () => {
// render count, memoization tests
});
});Validation Pass
Validate each test:
- Test type matches mocking strategy
- Classification rules followed
- Edge cases target specific documented boundaries
- A11y tests use correct queries and assertions
- Performance tests have clear thresholds
Classification Enforcement
| Classification | Must Use | Must Avoid |
| PRESENTATIONAL | getBy*, sync assertions | waitFor, findBy*, store mocks, Tauri mocks |
| STATEFUL-SIMPLE | Local state testing | Tauri mocks, race condition tests |
| STATEFUL-CONNECTED | Real stores, Tauri mocks | Mocking stores |
| CUSTOM-HOOK | renderHook, act | Component rendering |
| CONTEXT-PROVIDER | Provider wrapper, useContext | Direct state access |
| ROUTE-COMPONENT | Memory router, navigation | Direct component render |
Required Imports
// Core
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
import { render, screen, waitFor, within, act, fireEvent } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
// Hooks
import { renderHook } from '@testing-library/react';
// Routing
import { createMemoryRouter, RouterProvider } from 'react-router-dom';
// Accessibility
import { axe, toHaveNoViolations } from 'jest-axe';
// Performance
import { Profiler } from 'react';Phase 1 Output Format
## Target Identified
[Type]: [Name] at [path]
## Behavior Code├── file:line — "quoted code" └── file:line — "quoted code"
## Dependencies
- Tauri: [commands/events or "None"]
- Stores: [stores or "None"]
- Contexts: [contexts or "None"]
- Router: [yes/no]
## Edge Cases Identified
| Category | Edge Case | Code Reference | Handled? |
|----------|-----------|----------------|----------|
| [cat] | [description] | [file:line or —] | ✓/? |
## Classification
[TYPE] — [justification]
## Test Types
[list with justification]
## Planned Files
[list with test type]
## Mock Requirements
[structured by category]
## Behaviors
### [TEST TYPE] — Core
1. [trigger] → [outcome] → [pattern]
### [TEST TYPE] — Edge Cases
N. [EDGE: category] [trigger] → [outcome] → [pattern]
### Accessibility (if applicable)
N. [trigger] → [outcome] → [a11y]
---
Phase 1 complete. Reply "proceed" to generate tests.Phase 2 Output Format
## Validation
[✓/✗ for each test]
## Test Files
### [filename]
```typescript
[full code with organized describe blocks]
```
---
## References
- `references/edge-case-patterns.md` — Comprehensive edge cases by component/category type
- `references/test-examples.md` — Code templates for all test types (unit, integration, hook, context, a11y, router, DnD, virtualization, animation, performance, snapshot, Tauri system)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.

