Find test files impacted by code changes using static dependency analysis
npm install impactedIt takes a list of changed files, builds a dependency graph from your test files by statically analyzing their imports, and returns only the test files that depend on the changed files.
A userland implementation of predictive test selection for Node.js test runner.

``bashRun only impacted tests (--since gets changed files from git diff)
node --test $(npx impacted --since main)
GitHub Action
`yaml
- uses: actions/checkout@v4
with:
fetch-depth: 0- uses: sozua/impacted@v1
id: impacted
with:
pattern: '*/.{test,spec}.{js,mjs,cjs,jsx,ts,mts,cts,tsx}' # default
- name: Run impacted tests
if: steps.impacted.outputs.has-impacted == 'true'
run: node --test ${{ steps.impacted.outputs.files }}
`See action.yml for all inputs and outputs.
Programmatic API
`javascript
import { findImpacted } from 'impacted';const tests = await findImpacted({
changedFiles: ['src/utils.js'],
testFiles: 'test/*/.test.js',
cacheFile: '.impacted-cache.json', // optional
});
`$3
`javascript
import { run } from 'node:test';
import { findImpacted } from 'impacted';const files = await findImpacted({
changedFiles: ['src/utils.js'],
testFiles: 'test/*/.test.js',
});
run({ files });
`See examples/05-node-test-run for a full working example.
TypeScript
TypeScript files (
.ts, .mts, .cts, .tsx) are supported out of the box on Node.js >= 22.7. Type stripping is handled via node:module.stripTypeScriptTypes() — no additional dependencies required.Follows Node.js core's TypeScript philosophy: explicit extensions, no
tsconfig.json, no path aliases.Limitations
- Static analysis only — dynamic
require(variable) not supported
- Local files only — node_modules` changes won't trigger tests- Node.js >= 18 (TypeScript support requires >= 22.7)
MIT