t
test-staged
A lightweight CLI tool to run tests on git-staged files before commit pushes.
test-staged is a lightweight, zero-dependency CLI utility designed to run test files associated only with git-staged changes. By parsing the git diff index, it runs relevant unit tests before commit pushes, maintaining clean commits.
Key Features of test-staged
- Git-Staged Filtering: Scans modified code files to find and execute matching test files.
- Multi-Runner Support: Highly compatible with Jest, Mocha, Pytest, Vitest, and Playwright execution paths.
- Husky Hook Ready: Ideal for pre-commit workflows with minimal setup instructions.
- Output Formatting: Displays clear console reports showing files tested and exit codes.
Benefits of Using test-staged
- Boost Local Speed: Skip running the entire test suite on every minor change; only test the files you modified.
- Pre-commit Cleanliness: Prevents broken code from being committed to local or remote branch repositories.
- Low Setup Complexity: Simple, declarative configuration options directly inside package.json or config files.
To maintain test code quality, test-staged allows automation developers to run linting and unit checks specifically on staged test files, preventing broken scripts from reaching the main branch.
Tags:
Pre-commitTest RunnerZero ConfigCLIGit Hooks


