hooks-configs/hook-test-runner
Run tests related to changed files before committing
Pre-commit hook that runs tests for changed files. Uses test framework's built-in related test detection to only run relevant tests, keeping commits fast while ensuring coverage.
Content
{
"hooks": {
"pre-commit": [
{
"name": "test-related",
"command": "npx jest --bail --findRelatedTests",
"match": "**/*.{js,jsx,ts,tsx}",
"description": "Run tests related to changed files"
}
]
}
}Details
| Category | hooks-configs |
| Tags | testingpre-commitautomationintermediate |
| License | MIT |
| Author | Claude Code Directory |
| Difficulty | intermediate |
Pairs with
hooks-configs/hook-typescript-check
Validate TypeScript types before committing
hooks-configs/hook-build-check
Verify the project builds successfully before committing
hooks-configs/hook-security-audit
Check for dependency vulnerabilities before committing
hooks-configs/hook-commit-message
Enforce conventional commit message format