diff --git a/docs/Configuration.md b/docs/Configuration.md index 466e1a55c899..d0e451c508f1 100644 --- a/docs/Configuration.md +++ b/docs/Configuration.md @@ -761,20 +761,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'` diff --git a/website/versioned_docs/version-28.0/Configuration.md b/website/versioned_docs/version-28.0/Configuration.md index a8b148154fb1..bedcb2b75463 100644 --- a/website/versioned_docs/version-28.0/Configuration.md +++ b/website/versioned_docs/version-28.0/Configuration.md @@ -761,20 +761,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'` diff --git a/website/versioned_docs/version-28.1/Configuration.md b/website/versioned_docs/version-28.1/Configuration.md index 466e1a55c899..d0e451c508f1 100644 --- a/website/versioned_docs/version-28.1/Configuration.md +++ b/website/versioned_docs/version-28.1/Configuration.md @@ -761,20 +761,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'`