diff --git a/docs/Configuration.md b/docs/Configuration.md index 8cc5493f7864..f13e55bcdf11 100644 --- a/docs/Configuration.md +++ b/docs/Configuration.md @@ -333,6 +333,26 @@ Default: `undefined` This option allows the use of a custom global setup module which exports an async function that is triggered once before all test suites. This function gets Jest's `globalConfig` object as a parameter. +_Note: Any global variables that are defined through `globalSetup` can only be read in `globalTeardown`. You cannot retrieve globals defined here in your test suites._ + +Example: + +```js +// setup.js +module.exports = async () => { + // ... + // Set reference to mongod in order to close the server during teardown. + global.__MONGOD__ = mongod; +}; +``` + +```js +// teardown.js +module.exports = async function() { + await global.__MONGOD__.stop(); +}; +``` + ### `globalTeardown` [string] Default: `undefined`