-
Notifications
You must be signed in to change notification settings - Fork 452
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* feat(config): specify package.json location (#823) * fix(docs): package.json config option (#823) Document the package.json config option.
- Loading branch information
1 parent
279edcd
commit fb7dd55
Showing
7 changed files
with
171 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 `<rootDir>` in the path to start from the project root dir. | ||
|
||
<div class="row"><div class="col-md-6" markdown="block"> | ||
|
||
```js | ||
// jest.config.js | ||
module.exports = { | ||
// [...] | ||
globals: { | ||
'ts-jest': { | ||
packageJson: 'package.json' | ||
} | ||
} | ||
}; | ||
``` | ||
|
||
</div><div class="col-md-6" markdown="block"> | ||
|
||
```js | ||
// OR from a non-trivial path | ||
// jest.config.js | ||
module.exports = { | ||
// [...] | ||
globals: { | ||
'ts-jest': { | ||
packageJson: '<rootDir>/../../shared/package.json' | ||
} | ||
} | ||
}; | ||
``` | ||
|
||
</div></div> | ||
|
||
#### Inline package metadata | ||
|
||
<div class="row"><div class="col-md-12" markdown="block"> | ||
|
||
```js | ||
// jest.config.js | ||
module.exports = { | ||
// [...] | ||
globals: { | ||
'ts-jest': { | ||
packageJson: { | ||
"name": "my-project", | ||
"version": "1.0.0", | ||
"dependencies": { | ||
// [...] | ||
} | ||
} | ||
} | ||
} | ||
}; | ||
``` | ||
|
||
</div></div> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters