Skip to content

Commit

Permalink
Doc: rootdir affects preset resolution (#12817)
Browse files Browse the repository at this point in the history
  • Loading branch information
dimitropoulos committed May 13, 2022
1 parent 017a438 commit 7b6da60
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 24 deletions.
24 changes: 16 additions & 8 deletions docs/Configuration.md
Expand Up @@ -769,20 +769,28 @@ A preset that is used as a base for Jest's configuration. A preset should point

For example, this preset `foo-bar/jest-preset.js` will be configured as follows:

```json
{
"preset": "foo-bar"
}
```js
/** @type { import('@jest/types').Config.InitialOptions } */
module.exports = {
preset: 'foo-bar',
};
```

Presets may also be relative to filesystem paths.

```json
{
"preset": "./node_modules/foo-bar/jest-preset.js"
}
```js
/** @type { import('@jest/types').Config.InitialOptions } */
module.exports = {
preset: './node_modules/foo-bar/jest-preset.js',
};
```

:::info

Note that if you also have specified [`rootDir`](#rootdir-string) that the resolution of this file will be relative to that root directory.

:::

### `prettierPath` \[string]

Default: `'prettier'`
Expand Down
24 changes: 16 additions & 8 deletions website/versioned_docs/version-28.0/Configuration.md
Expand Up @@ -769,20 +769,28 @@ A preset that is used as a base for Jest's configuration. A preset should point

For example, this preset `foo-bar/jest-preset.js` will be configured as follows:

```json
{
"preset": "foo-bar"
}
```js
/** @type { import('@jest/types').Config.InitialOptions } */
module.exports = {
preset: 'foo-bar',
};
```

Presets may also be relative to filesystem paths.

```json
{
"preset": "./node_modules/foo-bar/jest-preset.js"
}
```js
/** @type { import('@jest/types').Config.InitialOptions } */
module.exports = {
preset: './node_modules/foo-bar/jest-preset.js',
};
```

:::info

Note that if you also have specified [`rootDir`](#rootdir-string) that the resolution of this file will be relative to that root directory.

:::

### `prettierPath` \[string]

Default: `'prettier'`
Expand Down
24 changes: 16 additions & 8 deletions website/versioned_docs/version-28.1/Configuration.md
Expand Up @@ -769,20 +769,28 @@ A preset that is used as a base for Jest's configuration. A preset should point

For example, this preset `foo-bar/jest-preset.js` will be configured as follows:

```json
{
"preset": "foo-bar"
}
```js
/** @type { import('@jest/types').Config.InitialOptions } */
module.exports = {
preset: 'foo-bar',
};
```

Presets may also be relative to filesystem paths.

```json
{
"preset": "./node_modules/foo-bar/jest-preset.js"
}
```js
/** @type { import('@jest/types').Config.InitialOptions } */
module.exports = {
preset: './node_modules/foo-bar/jest-preset.js',
};
```

:::info

Note that if you also have specified [`rootDir`](#rootdir-string) that the resolution of this file will be relative to that root directory.

:::

### `prettierPath` \[string]

Default: `'prettier'`
Expand Down

0 comments on commit 7b6da60

Please sign in to comment.