# jest-changed-files

> A module used internally by Jest to check which files have changed since you last committed in git or hg.

Latest version **30.5.1** (published 2026-09-01) · MIT license · 0 weekly downloads

## Install

```sh
npm install jest-changed-files
pnpm add jest-changed-files
yarn add jest-changed-files
bun add jest-changed-files
```

## Health

**Score 70/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; recently updated; high maintenance score; popular repo.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 30.5.1 |
| Published | 2026-09-01 |
| First published | 2016-05-11 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | ^18.14.0 \|\| ^20.0.0 \|\| ^22.0.0 \|\| >=24.0.0 |
| Dependencies | 3 |
| Unpacked size | 17.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 45460 |
| Maintainers | aaronabramov, simenb, rickhanlonii, openjs-operations, cpojer |

## Links

- npm: https://www.npmjs.com/package/jest-changed-files
- Repository: https://github.com/jestjs/jest
- Homepage: https://github.com/jestjs/jest#readme
- Issues: https://github.com/jestjs/jest/issues
- npm.io page: https://npm.io/package/jest-changed-files

## Dependencies (3)

- [execa](https://npm.io/package/execa.md) ^5.1.1
- [p-limit](https://npm.io/package/p-limit.md) ^3.1.0
- [jest-util](https://npm.io/package/jest-util.md) 30.5.1

## Recent versions

- 30.5.1 (latest) — 2026-09-01
- 30.0.0-rc.1 (next) — 2025-06-09
- 30.5.0 — 2026-08-28
- 30.4.1 — 2026-05-08
- 30.4.0 — 2026-05-07
- 30.3.0 — 2026-03-10
- 30.2.0 — 2025-09-28
- 30.0.5 — 2025-07-22
- 30.0.2 — 2025-06-19
- 30.0.1 — 2025-06-18
- 30.0.0 — 2025-06-10
- 30.0.0-beta.8 — 2025-06-04
- 30.0.0-beta.7 — 2025-06-04
- 30.0.0-beta.6 — 2025-06-03
- 30.0.0-beta.3 — 2025-05-27
- … 176 more at https://npm.io/package/jest-changed-files/versions

## README

# jest-changed-files

A module used internally by Jest to check which files have changed since you last committed in git or hg.

## Install

```sh
$ npm install --save jest-changed-files
```

## API

### `getChangedFilesForRoots(roots: Array<string>, options: Options): Promise<ChangedFiles>`

Get the list of files and repos that have changed since the last commit.

#### Parameters

roots: Array of string paths gathered from [jest roots](https://jestjs.io/docs/configuration#roots-arraystring).

options: Object literal with keys

- lastCommit: boolean
- withAncestor: boolean
- changedSince: string

### Returns

A Promise of Object literal with keys

- changedFiles: Set\<string>
- repos:
  - git: Set\<string>
  - hg: Set\<string>

### findRepos(roots: Array<string>): Promise<Repos>

Get a set of git and hg repositories.

#### Parameters

roots: Array of string paths gathered from [jest roots](https://jestjs.io/docs/configuration#roots-arraystring).

### Returns

A Promise of Object literal with keys

- git: Set\<string>
- hg: Set\<string>

## Usage

```javascript
import {getChangedFilesForRoots} from 'jest-changed-files';

getChangedFilesForRoots(['/path/to/test'], {
  lastCommit: true,
  withAncestor: true,
}).then(files => {
  /*
  {
    repos: [],
    changedFiles: []
  }
  */
});
```

```javascript
import {getChangedFilesForRoots} from 'jest-changed-files';

getChangedFilesForRoots(['/path/to/test'], {
  changedSince: 'main',
}).then(files => {
  /*
  {
    repos: [],
    changedFiles: []
  }
  */
});
```

```javascript
import {findRepos} from 'jest-changed-files';

findRepos(['/path/to/test']).then(repos => {
  /*
  {
    git: Set<Path>,
    hg: Set<Path>
  }
  */
});
```

---
_Source: https://npm.io/package/jest-changed-files · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
