BACK TO DIRECTORY
hookintermediate

Test Runner

Intelligently determines which test files are related to the staged changes and runs only those tests before allowing a commit. Uses Vitest's changed file detection to minimize test execution time while still catching regressions. Falls back to running the full test suite if the relationship cannot be determined.

467 STARS
7.1k DOWNLOADS
claude-templates
testingvitestjestpre-commitregression

CONFIGURATION

json
1{
2 "hooks": {
3 "pre-commit": {
4 "command": "npx vitest run --changed HEAD~1 --reporter=verbose",
5 "description": "Run tests related to staged changes",
6 "on_failure": "block",
7 "timeout": 120000,
8 "fallback": {
9 "command": "npx vitest run --reporter=dot",
10 "description": "Run full test suite if change detection fails"
11 }
12 }
13 },
14 "settings": {
15 "min_coverage": {
16 "statements": 80,
17 "branches": 70,
18 "functions": 75,
19 "lines": 80
20 },
21 "fail_on_coverage_decrease": true,
22 "parallel": true,
23 "max_workers": "50%"
24 },
25 "vitest_config_additions": {
26 "test": {
27 "globals": true,
28 "environment": "node",
29 "include": ["src/**/*.test.{ts,tsx}", "src/**/*.spec.{ts,tsx}"],
30 "coverage": {
31 "provider": "v8",
32 "reporter": ["text", "lcov"],
33 "exclude": ["node_modules", "dist", "**/*.d.ts"]
34 }
35 }
36 }
37}