Install command
Provided
Automatically creates or updates test files when React components are modified.
Open the source and read safety notes before installing.
Source-backed facts for citing this resource, derived directly from the registry — also available as plain text for AI assistants.
Decision playbook
Signals are present but mixed. Use the checklist below to confirm the source and operational safety for your environment.
0
78
—
No baseline selected
No major trust-signal divergence detected in the current selection.
Confirm ownership and provenance before trusting install instructions.
Source link availableRequired
Open the canonical repository and verify ownership.
Source provenance statusRequired
Marked as source-backed.
Metadata reviewed
Registry metadata indicates a reviewed listing.
Validate risk disclosures before installation or API wiring.
Safety notes presentRequired
Review the listed safety guidance before running commands.
Privacy notes presentRequired
Review data handling notes before connecting accounts or secrets.
Trust level risk gateRequired
Trust level does not block evaluation.
Check package metadata and artifact integrity signals.
Install payload available
Install or copy payload is available for review.
Package verification flag
No package verification flag provided.
Checksum metadata
No checksum provided for downloaded artifact.
Use compare context to validate trade-offs before adoption.
Compare tray has multiple entries
Add at least one more entry to compare trust differences.
Baseline comparison available
No baseline peer selected yet.
Diverging trust signals identified
No major trust-signal divergence found.
Setup at a glance
Copy-ready — paste the snippet to get started.
Install command
Provided
Config snippet
Provided
Copy snippet
Provided
Prerequisites
None
Platforms
1 listed
Difficulty
0/100
Adoption plan
Current risk score 16/100. Use staged verification before broader rollout.
Validate source and review signals before any execution.
Confirm source provenanceRequired
Source URL/provenance metadata is present.
Confirm metadata review state
Listing has review metadata.
Verify install payload
Install/config payload exists and can be inspected.
Confirm safety, privacy, and package integrity signals.
Review safety notesRequired
Safety notes are present.
Review privacy notesRequired
Privacy notes are present.
Verify package integrity metadata
No package verification/checksum metadata.
Adopt in controlled steps based on the selected plan.
Run in isolated sandbox firstRequired
Use a constrained sandbox and observe behavior across multiple tasks.
Roll out graduallyRequired
Roll out to a small cohort before wider usage.
Set monitoring and fallback
Define rollback path and monitor errors after adoption.
Evidence readiness
Required evidence gates are covered (5/6 signals complete).
Source repository/provenance is listed.
Required in this preset
Review metadata is present.
Required in this preset
Safety notes are present.
Required in this preset
Privacy notes are present.
Optional in this preset
Package integrity metadata is missing.
Optional in this preset
Install payload is available.
Required in this preset
Required evidence gates are covered for this preset.
Decision timeline
5/6 steps complete with no blocking gaps for this preset.
triage
Source/provenance metadata is available.
triage
Review metadata is available.
verify
Safety notes are available.
verify
Privacy notes are available.
verify
Package integrity metadata is missing.
rollout
Install payload is available.
No required blockers for this timeline preset.
Safety & privacy surface
1 safety and 1 privacy notes across 2 risk areas. Review closely: credentials & tokens, permissions & scopes.
#!/bin/bash
# Read the tool input from stdin
INPUT=$(cat)
TOOL_NAME=$(echo "$INPUT" | jq -r '.tool_name')
FILE_PATH=$(echo "$INPUT" | jq -r '.tool_input.file_path // .tool_input.path // ""')
if [ -z "$FILE_PATH" ]; then
exit 0
fi
# Check if this is a React component file (but not a test file)
if [[ "$FILE_PATH" == *.jsx ]] || [[ "$FILE_PATH" == *.tsx ]]; then
# Skip if this is already a test file
if [[ "$FILE_PATH" == *.test.* ]] || [[ "$FILE_PATH" == *.spec.* ]]; then
exit 0
fi
echo "⚛️ React Component Test Generator - Processing component..."
echo "📄 Component: $FILE_PATH"
# Extract component info
COMPONENT_DIR=$(dirname "$FILE_PATH")
COMPONENT_BASENAME=$(basename "$FILE_PATH")
COMPONENT_NAME=$(basename "${FILE_PATH%.*}")
COMPONENT_EXT="${FILE_PATH##*.}"
# Determine test file path
if [[ "$COMPONENT_EXT" == "tsx" ]]; then
TEST_FILE="${COMPONENT_DIR}/${COMPONENT_NAME}.test.tsx"
else
TEST_FILE="${COMPONENT_DIR}/${COMPONENT_NAME}.test.jsx"
fi
# Check if test file already exists
if [ -f "$TEST_FILE" ]; then
echo "ℹ️ Test file already exists: $TEST_FILE"
echo "💡 Consider updating tests to match component changes"
else
echo "🧪 Generating test file: $TEST_FILE"
# Create test file content
cat > "$TEST_FILE" << EOF
import { render, screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import $COMPONENT_NAME from './$COMPONENT_BASENAME';
describe('$COMPONENT_NAME', () => {
it('renders without crashing', () => {
render(<$COMPONENT_NAME />);
});
it('displays expected content', () => {
render(<$COMPONENT_NAME />);
// Add assertions here
// expect(screen.getByText('expected text')).toBeInTheDocument();
});
// Add more component-specific tests here
// Example: testing props, user interactions, etc.
//
// it('handles user interactions', async () => {
// const user = userEvent.setup();
// render(<$COMPONENT_NAME />);
// // await user.click(screen.getByRole('button'));
// // expect(...);
// });
});
EOF
if [ $? -eq 0 ]; then
echo "✅ Test file created successfully!"
echo "📝 Test file: $TEST_FILE"
else
echo "❌ Failed to create test file"
fi
fi
# Additional suggestions based on component analysis
echo ""
echo "🔍 Component Analysis:"
if [ -f "$FILE_PATH" ]; then
# Check for props interface/type
if grep -q "interface.*Props\|type.*Props" "$FILE_PATH"; then
echo " • 💡 Props interface detected - consider testing different prop combinations"
fi
# Check for hooks usage
if grep -q "useState\|useEffect\|useContext" "$FILE_PATH"; then
echo " • 💡 React hooks detected - consider testing state changes and side effects"
fi
# Check for event handlers
if grep -q "onClick\|onChange\|onSubmit" "$FILE_PATH"; then
echo " • 💡 Event handlers detected - consider testing user interactions"
fi
# Check for conditional rendering
if grep -q "&&\|?.*:" "$FILE_PATH"; then
echo " • 💡 Conditional rendering detected - test different rendering scenarios"
fi
fi
echo ""
echo "💡 Testing Best Practices:"
echo " • Test component behavior, not implementation details"
echo " • Use accessible queries (getByRole, getByLabelText)"
echo " • Test user interactions with userEvent"
echo " • Mock external dependencies and API calls"
echo " • Test edge cases and error states"
echo ""
echo "🎯 Test generation complete!"
else
echo "ℹ️ File is not a React component: $FILE_PATH"
fi
exit 0{
"hooks": {
"postToolUse": {
"script": "./.claude/hooks/react-component-test-generator.sh",
"matchers": [
"write",
"edit"
]
}
}
}.claude/settings.local.json~/.claude/settings.json.claude/settings.json{
"hooks": {
"postToolUse": {
"script": "./.claude/hooks/react-component-test-generator.sh",
"matchers": ["write", "edit"]
}
}
}
#!/bin/bash
# Read the tool input from stdin
INPUT=$(cat)
TOOL_NAME=$(echo "$INPUT" | jq -r '.tool_name')
FILE_PATH=$(echo "$INPUT" | jq -r '.tool_input.file_path // .tool_input.path // ""')
if [ -z "$FILE_PATH" ]; then
exit 0
fi
# Check if this is a React component file (but not a test file)
if [[ "$FILE_PATH" == *.jsx ]] || [[ "$FILE_PATH" == *.tsx ]]; then
# Skip if this is already a test file
if [[ "$FILE_PATH" == *.test.* ]] || [[ "$FILE_PATH" == *.spec.* ]]; then
exit 0
fi
echo "⚛️ React Component Test Generator - Processing component..."
echo "📄 Component: $FILE_PATH"
# Extract component info
COMPONENT_DIR=$(dirname "$FILE_PATH")
COMPONENT_BASENAME=$(basename "$FILE_PATH")
COMPONENT_NAME=$(basename "${FILE_PATH%.*}")
COMPONENT_EXT="${FILE_PATH##*.}"
# Determine test file path
if [[ "$COMPONENT_EXT" == "tsx" ]]; then
TEST_FILE="${COMPONENT_DIR}/${COMPONENT_NAME}.test.tsx"
else
TEST_FILE="${COMPONENT_DIR}/${COMPONENT_NAME}.test.jsx"
fi
# Check if test file already exists
if [ -f "$TEST_FILE" ]; then
echo "ℹ️ Test file already exists: $TEST_FILE"
echo "💡 Consider updating tests to match component changes"
else
echo "🧪 Generating test file: $TEST_FILE"
# Create test file content
cat > "$TEST_FILE" << EOF
import { render, screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import $COMPONENT_NAME from './$COMPONENT_BASENAME';
describe('$COMPONENT_NAME', () => {
it('renders without crashing', () => {
render(<$COMPONENT_NAME />);
});
it('displays expected content', () => {
render(<$COMPONENT_NAME />);
// Add assertions here
// expect(screen.getByText('expected text')).toBeInTheDocument();
});
// Add more component-specific tests here
// Example: testing props, user interactions, etc.
//
// it('handles user interactions', async () => {
// const user = userEvent.setup();
// render(<$COMPONENT_NAME />);
// // await user.click(screen.getByRole('button'));
// // expect(...);
// });
});
EOF
if [ $? -eq 0 ]; then
echo "✅ Test file created successfully!"
echo "📝 Test file: $TEST_FILE"
else
echo "❌ Failed to create test file"
fi
fi
# Additional suggestions based on component analysis
echo ""
echo "🔍 Component Analysis:"
if [ -f "$FILE_PATH" ]; then
# Check for props interface/type
if grep -q "interface.*Props\|type.*Props" "$FILE_PATH"; then
echo " • 💡 Props interface detected - consider testing different prop combinations"
fi
# Check for hooks usage
if grep -q "useState\|useEffect\|useContext" "$FILE_PATH"; then
echo " • 💡 React hooks detected - consider testing state changes and side effects"
fi
# Check for event handlers
if grep -q "onClick\|onChange\|onSubmit" "$FILE_PATH"; then
echo " • 💡 Event handlers detected - consider testing user interactions"
fi
# Check for conditional rendering
if grep -q "&&\|?.*:" "$FILE_PATH"; then
echo " • 💡 Conditional rendering detected - test different rendering scenarios"
fi
fi
echo ""
echo "💡 Testing Best Practices:"
echo " • Test component behavior, not implementation details"
echo " • Use accessible queries (getByRole, getByLabelText)"
echo " • Test user interactions with userEvent"
echo " • Mock external dependencies and API calls"
echo " • Test edge cases and error states"
echo ""
echo "🎯 Test generation complete!"
else
echo "ℹ️ File is not a React component: $FILE_PATH"
fi
exit 0
Complete hook script that generates React component test files
#!/bin/bash
INPUT=$(cat)
FILE_PATH=$(echo "$INPUT" | jq -r '.tool_input.file_path // .tool_input.path // ""')
if [ -z "$FILE_PATH" ]; then
exit 0
fi
if [[ "$FILE_PATH" == *.jsx ]] || [[ "$FILE_PATH" == *.tsx ]]; then
if [[ "$FILE_PATH" == *.test.* ]] || [[ "$FILE_PATH" == *.spec.* ]]; then
exit 0
fi
COMPONENT_DIR=$(dirname "$FILE_PATH")
COMPONENT_NAME=$(basename "${FILE_PATH%.*}")
COMPONENT_EXT="${FILE_PATH##*.}"
if [[ "$COMPONENT_EXT" == "tsx" ]]; then
TEST_FILE="${COMPONENT_DIR}/${COMPONENT_NAME}.test.tsx"
else
TEST_FILE="${COMPONENT_DIR}/${COMPONENT_NAME}.test.jsx"
fi
if [ ! -f "$TEST_FILE" ]; then
echo "🧪 Generating test file: $TEST_FILE"
cat > "$TEST_FILE" << 'EOF'
import { render, screen } from '@testing-library/react';
import ComponentName from './ComponentName';
describe('ComponentName', () => {
it('renders without crashing', () => {
render(<ComponentName />);
});
});
EOF
fi
fi
exit 0
Complete hook configuration for .claude/settings.json to enable React component test generation
{
"hooks": {
"postToolUse": {
"script": "./.claude/hooks/react-component-test-generator.sh",
"matchers": ["write", "edit"]
}
}
}
Enhanced hook script with component analysis and test recommendations
#!/bin/bash
INPUT=$(cat)
FILE_PATH=$(echo "$INPUT" | jq -r '.tool_input.file_path // .tool_input.path // ""')
if [[ "$FILE_PATH" == *.jsx ]] || [[ "$FILE_PATH" == *.tsx ]]; then
if [[ "$FILE_PATH" == *.test.* ]] || [[ "$FILE_PATH" == *.spec.* ]]; then
exit 0
fi
COMPONENT_DIR=$(dirname "$FILE_PATH")
COMPONENT_NAME=$(basename "${FILE_PATH%.*}")
COMPONENT_EXT="${FILE_PATH##*.}"
if [[ "$COMPONENT_EXT" == "tsx" ]]; then
TEST_FILE="${COMPONENT_DIR}/${COMPONENT_NAME}.test.tsx"
else
TEST_FILE="${COMPONENT_DIR}/${COMPONENT_NAME}.test.jsx"
fi
if [ ! -f "$TEST_FILE" ]; then
echo "🧪 Generating test file: $TEST_FILE"
if grep -q "interface.*Props\|type.*Props" "$FILE_PATH"; then
echo " • Props interface detected - generating props tests"
fi
if grep -q "useState\|useEffect\|useContext" "$FILE_PATH"; then
echo " • React hooks detected - generating hooks tests"
fi
if grep -q "onClick\|onChange\|onSubmit" "$FILE_PATH"; then
echo " • Event handlers detected - generating interaction tests"
fi
fi
fi
exit 0
Example of a complete React component test with user interactions using React Testing Library
import { render, screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import Button from './Button';
describe('Button', () => {
it('renders without crashing', () => {
render(<Button />);
});
it('displays button text', () => {
render(<Button>Click me</Button>);
expect(screen.getByRole('button', { name: /click me/i })).toBeInTheDocument();
});
it('handles click events', async () => {
const handleClick = jest.fn();
const user = userEvent.setup();
render(<Button onClick={handleClick}>Click me</Button>);
await user.click(screen.getByRole('button'));
expect(handleClick).toHaveBeenCalledTimes(1);
});
});
Example Jest configuration for React component testing
{
"jest": {
"testEnvironment": "jsdom",
"setupFilesAfterEnv": ["<rootDir>/src/setupTests.ts"],
"moduleNameMapper": {
"^@/(.*)$": "<rootDir>/src/$1"
}
}
}
Hook assumes default exports. For named exports, modify the template to use: import { ComponentName } from './file'. Check component export pattern before generation or add detection logic for export type. Verify component exports. Test with various export patterns.
Base template uses empty props . Extract props interface from component file using grep and generate mock props: const mockProps = { required: 'value' }; before render() call in template. Verify props interface. Test with various prop configurations.
Hook doesn't verify testing dependencies. Add package.json check: grep -q '@testing-library/react' package.json || { echo 'Install testing libraries first'; exit 1; } before generating test files. Verify package.json. Test with various dependency configurations.
PostToolUse triggers immediately after tool but writes may be buffered. Add validation: [ -s "$FILE_PATH" ] to check file has content before reading. Use sleep 0.05 if race conditions persist in analysis section. Verify file content. Test with various file write scenarios.
Template uses unquoted $COMPONENT_NAME in heredoc. Escape special characters: SAFE_NAME=${COMPONENTNAME//[^a-zA-Z0-9]/} or use single quotes: cat > "$TEST_FILE" <<'EOF' to prevent variable expansion issues. Verify component names. Test with various component name patterns.
Ensure TypeScript configuration is correct and @types/react is installed. Verify tsconfig.json includes test files. Check type definitions for React Testing Library. Verify TypeScript setup. Test with various TypeScript configurations.
Verify import paths are correct relative to test file location. Check component file exists and export is correct. Ensure Jest module resolution is configured properly. Verify file structure. Test with various project structures.
Customize test template to match project standards. Add project-specific test utilities and patterns. Configure test generation to use project-specific templates. Verify project standards. Test with various project configurations.
React Test Generator side by side with 3 alternatives on trust, install, platform support, and disclosed safety notes — all from reviewed registry metadata.
| Field | Automatically creates or updates test files when React components are modified. Open dossier | Automatically updates Jest snapshots when component files are modified significantly. Open dossier | A PostToolUse hook that runs the matching test runner for a changed file's language — Jest or Vitest for JS/TS, pytest for Python, go test, or Maven/Gradle for Java — scoped to the edited file. Open dossier | Automatically runs Playwright E2E tests when test files or page components are modified. Open dossier |
|---|---|---|---|---|
| Next steps | ||||
| Trust | ||||
| Review status | ReviewedMaintainer reviewed | ReviewedMaintainer reviewed | ReviewedMaintainer reviewed | ReviewedMaintainer reviewed |
| Package trust | Package not verified | Package not verified | Package not verified | Package not verified |
| Source provenance | Source-backed | Source-backed | Source-backed | Source-backed |
| Submitter | — | — | — | — |
| Install risk | Review first | Review first | Review first | Review first |
| Notes | Safety ✓ Privacy ✓ | Safety ✓ Privacy ✓ | Safety ✓ Privacy ✓ | Safety ✓ Privacy ✓ |
| Brand | — | — | — | — |
| Category | hooks | hooks | hooks | hooks |
| Source | source-backed | source-backed | source-backed | source-backed |
| Author | JSONbored | JSONbored | JSONbored | JSONbored |
| Added | 2025-09-19 | 2025-09-19 | 2025-09-16 | 2025-09-19 |
| Platforms | Claude Code | Claude Code | Claude Code | Claude Code |
| Source repo | — | — | — | — |
| Safety notes | ✓Runs automatically on its configured Claude Code hook event and executes shell logic that can read, modify, or delete files in your project (and may run builds, installs, or network calls); review the script and scope it to expected paths before enabling. | ✓Runs automatically on its configured Claude Code hook event and executes shell logic that can read, modify, or delete files in your project (and may run builds, installs, or network calls); review the script and scope it to expected paths before enabling. | ✓Runs your project's test command automatically after each edit; tests execute arbitrary project code, so enable this only in a trusted repo and expect it to run frequently. The script invokes whichever runner it detects (npm test, npx vitest, pytest, go test, mvn/gradle); make sure the right one is installed so it does not run an unexpected command. | ✓Runs automatically on its configured Claude Code hook event and executes shell logic that can read, modify, or delete files in your project (and may run builds, installs, or network calls); review the script and scope it to expected paths before enabling. |
| Privacy notes | ✓Receives Claude Code hook input (session metadata, file paths, and tool output) and reads local project files; review what the script logs or forwards to external services and keep credentials out of its output. | ✓Receives Claude Code hook input (session metadata, file paths, and tool output) and reads local project files; review what the script logs or forwards to external services and keep credentials out of its output. | ✓Runs locally and prints test output to the hook; that output can include file paths, test names, and any data your tests log. | ✓Receives Claude Code hook input (session metadata, file paths, and tool output) and reads local project files; review what the script logs or forwards to external services and keep credentials out of its output. |
| Prerequisites | — none listed | — none listed | — none listed | — none listed |
| Install | | | | |
| Config | | | | |
| Citations | ||||
| Claim | Unclaimed | Unclaimed | Unclaimed | Unclaimed |
Source-backed guides for putting this to work.
Set autoMode.hard_deny rules to block risky actions in auto mode.
Loading live community signals…
A short, calm digest of reviewed Claude resources. Unsubscribe any time.