Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 9 additions & 31 deletions docs/UpgradingToJest30.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,41 +77,19 @@ If your project contains files with these extensions that are **not** intended t

:::

### `testPathPattern` Renamed to `testPathPatterns`
### `--testPathPattern` Renamed to `--testPathPatterns`

If you filter tests by path, note that the configuration option and CLI flag have changed:
If you filter tests by path, note that the CLI flag has changed: The `--testPathPattern` flag is now `--testPathPatterns`. You can pass multiple patterns by separating them with spaces or by repeating the flag. For example:

- **Configuration:** The `testPathPattern` option (singular) has been replaced by `testPathPatterns` (plural). Instead of a single regex string, this option now takes an array of patterns. For example:

Jest 29 configuration:

```js
export default {
testPathPattern: 'e2e/.*\\.spec\\.js',
};
```

Jest 30 configuration:

```js
export default {
testPathPatterns: ['e2e/.*\\.spec\\.js'],
};
```

Each pattern in the array is treated as a regex or glob to match test file paths.

- **CLI usage:** The `--testPathPattern` flag is now `--testPathPatterns`. You can pass multiple patterns by separating them with spaces or by repeating the flag. For example:

```bash
# Old (Jest 29)
jest --testPathPattern="unit/.*"
```bash
# Old (Jest 29)
jest --testPathPattern="unit/.*"

# New (Jest 30)
jest --testPathPatterns "unit/.*" "integration/.*"
```
# New (Jest 30)
jest --testPathPatterns "unit/.*" "integration/.*"
```

Internally, Jest consolidates these patterns into a `TestPathPatterns` object. If you were programmatically calling Jest’s watch mode with a `testPathPattern`, you must now construct a `TestPathPatterns` instance instead.
Internally, Jest consolidates these patterns into a `TestPathPatterns` object. If you were programmatically calling Jest’s watch mode with a `testPathPattern`, you must now construct a `TestPathPatterns` instance instead.

### Removed `--init` Command

Expand Down
Loading