test-impact
v0.1.0
Published
Analyze changed files and run only impacted tests using a dependency graph
Downloads
16
Maintainers
Readme
test-impact
test-impact is a Node CLI that finds changed files in git, builds a project dependency graph, and runs only impacted tests.
Why this matters
Large TypeScript repos can spend most CI time running unaffected tests. test-impact narrows test execution to only files impacted by dependency changes.
How it works
- Read changed files from
git diff --name-only HEAD(or--base=<branch>). - Scan project
.tsand.jsfiles. - Parse imports with lightweight regex parser.
- Build directed dependency graph and reverse graph.
- Traverse reverse graph from changed files.
- Select reachable test files (
.test.ts/.spec.ts). - Print impacted tests and run
vitestunless--dry-run.
Installation
npm install -D test-impactUsage
npx test-impact --dry-run
npx test-impact --base=main
npx test-impact --base=origin/main --verboseExample output
Impacted test files:
- src/service/user.test.ts
- src/service/auth.spec.ts
Summary: 2 impacted test(s)Example repo demo
Fixture repo and tests are under test/fixtures/repo.
npm testPerformance comparison (illustrative)
| Mode | Tests executed | Runtime | | --- | --- | --- | | Full suite | 1,200 | 4m 40s | | test-impact | 86 | 31s |
v2 roadmap
- Watch mode
- Graph caching
- Jest runner integration
- TypeScript Compiler API import parsing
