Skip to content
/ impacted Public

Static dependency analysis to find which tests are impacted by code changes.

Notifications You must be signed in to change notification settings

sozua/impacted

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

impacted

Find test files impacted by code changes using static dependency analysis.

A userland implementation of predictive test selection for Node.js test runner.

npm version

Usage

# Run only impacted tests
node --test $(git diff --name-only main | npx impacted)

# Works with any test runner
vitest $(git diff --name-only main | npx impacted)
jest $(git diff --name-only main | npx impacted)

# Custom test pattern
git diff --name-only main | npx impacted -p "src/**/*.spec.js"

GitHub Action

- uses: sozua/impacted@v1
  id: impacted
  with:
    pattern: '**/*.test.js'

- 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

import { findImpacted } from 'impacted';

const tests = await findImpacted({
  changedFiles: ['src/utils.js'],
  testFiles: 'test/**/*.test.js',
  cacheFile: '.impacted-cache.json', // optional
});

How it works

Builds a dependency graph from your test files, inverts it, and walks from changed files to find impacted tests.

src/utils.js (changed)
    ↓ imported by
src/parser.js
    ↓ imported by
test/parser.test.js (impacted)

Limitations

  • JavaScript only (.js, .mjs, .cjs, .jsx) — no TypeScript yet
  • Static analysis only — dynamic require(variable) not supported
  • Local files only — node_modules changes won't trigger tests

Requirements

  • Node.js >= 18

License

MIT