diff --git a/docs/user/config/index.md b/docs/user/config/index.md index 283b46c579..7d7eda3bd8 100644 --- a/docs/user/config/index.md +++ b/docs/user/config/index.md @@ -193,6 +193,7 @@ All options have default values which should fit most of the projects. Click on | [**`diagnostics`**][diagnostics] | [Diagnostics related configuration.][diagnostics] | `boolean`\|`object` | `true` | | [**`babelConfig`**][babelConfig] | [Babel(Jest) related configuration.][babelConfig] | `boolean`\|`object` | _disabled_ | | [**`stringifyContentPathRegex`**][stringifyContentPathRegex] | [Files which will become modules returning self content.][stringifyContentPathRegex] | `string`\|`RegExp` | _disabled_ | +| [**`packageJson`**][packageJson] | [Package metadata.][packageJson] | `string`\|`object`\|`boolean` | _auto_ | ### Upgrading @@ -222,3 +223,4 @@ npx ts-jest config:migrate package.json [diagnostics]: diagnostics [babelConfig]: babelConfig [stringifyContentPathRegex]: stringifyContentPathRegex +[packageJson]: packageJson diff --git a/docs/user/config/packageJson.md b/docs/user/config/packageJson.md new file mode 100644 index 0000000000..6d2343010a --- /dev/null +++ b/docs/user/config/packageJson.md @@ -0,0 +1,69 @@ +--- +title: packageJson Config option +--- + +The `packageJson` option specifies the `package.json` file to use. An inline object may also be specified instead of a file path. + +By default, the `package.json` file at the root of the project will be used. If it cannot be found, an empty project definition will be used instead. + +### Examples + +#### Path to a `packageJson` file + +The path should be relative to the current working directory where you start Jest from. You can also use `` in the path to start from the project root dir. + +
+ +```js +// jest.config.js +module.exports = { + // [...] + globals: { + 'ts-jest': { + packageJson: 'package.json' + } + } +}; +``` + +
+ +```js +// OR from a non-trivial path +// jest.config.js +module.exports = { + // [...] + globals: { + 'ts-jest': { + packageJson: '/../../shared/package.json' + } + } +}; +``` + +
+ +#### Inline package metadata + +
+ +```js +// jest.config.js +module.exports = { + // [...] + globals: { + 'ts-jest': { + packageJson: { + "name": "my-project", + "version": "1.0.0", + "dependencies": { + // [...] + } + } + } + } +}; +``` + +
+