Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Configuration.md #7455

Merged
merged 5 commits into from
Dec 17, 2018
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions docs/Configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,24 @@ 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.

The global variables that are configured through `global` object can be read in `globalTeardown` only, you cannot get `global` in your test suites:
codeaholicguy marked this conversation as resolved.
Show resolved Hide resolved

```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`
Expand Down