Add vitest related to pre-commit with expensive test skipping (#7854)

## Summary
This PR improves the pre-commit hook performance by:
- Using `vitest related` to run only tests affected by changed files
- Adding ability to skip expensive tests (filter tests) during
pre-commit
- Providing a consistent mechanism for skipping expensive tests

## Changes
- Modified `lint-staged.config.mjs` to run `vitest related` with
`SKIP_EXPENSIVE_TESTS=true`
- Updated `test/filter-tests.ts` to use idiomatic `describe.skipIf()`
for conditional test execution
- Changed `test-min` script to use `SKIP_EXPENSIVE_TESTS` environment
variable instead of `--exclude`
- Updated `CLAUDE.md` with documentation about the new test workflow

## Impact
- Pre-commit hooks are now much faster as they:
  - Only run tests related to changed files
  - Skip 688 expensive filter tests
  - Use the same skipping mechanism as `npm run test-min`

## Testing
-  Verified `vitest related` correctly identifies and runs related
tests
-  Confirmed filter tests are skipped when `SKIP_EXPENSIVE_TESTS=true`
-  Tested that full test suite still runs all tests when env var is not
set
-  Pre-commit hooks work correctly with the new setup

🤖 Generated with [Claude Code](https://claude.ai/code)

---------

Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
Matt Godbolt
2025-06-22 14:34:16 -05:00
committed by GitHub
parent bb08a6042a
commit 577094cf11
6 changed files with 16 additions and 5 deletions

View File

@@ -147,7 +147,7 @@
"test-coverage": "vitest run --coverage",
"test": "vitest run",
"test:watch": "vitest",
"test-min": "vitest run --exclude test/filter-tests.ts",
"test-min": "cross-env SKIP_EXPENSIVE_TESTS=true vitest run",
"check": "npm run ts-check && npm run lint-check && npm run check-frontend-imports && npm run test-min -- --reporter dot",
"check-frontend-imports": "node ./etc/scripts/check-frontend-imports.js",
"dev": "cross-env NODE_ENV=DEV node --no-warnings=ExperimentalWarning --import=tsx app.ts",