diff --git a/CHANGELOG.md b/CHANGELOG.md index f0fa49a26b8a..a80f9d1efce5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -48,6 +48,8 @@ ([#5864](https://github.com/facebook/jest/pull/5864)) * `[jest-editor-support]` Add `no-color` option to runner ([#5909](https://github.com/facebook/jest/pull/5909)) +* `[jest-cli]` Added support to access configuration from `globalSetup` and + `globalTeardown` ([#5961](https://github.com/facebook/jest/pull/5961)) ### Fixes diff --git a/docs/Configuration.md b/docs/Configuration.md index 10ef341fcd07..2e31b0b497a2 100644 --- a/docs/Configuration.md +++ b/docs/Configuration.md @@ -358,6 +358,9 @@ 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. +Jest's configuration object is passed as a parameter to the `globalSetup` +function. + ### `globalTeardown` [string] Default: `undefined` @@ -365,6 +368,9 @@ Default: `undefined` This option allows the use of a custom global teardown module which exports an async function that is triggered once after all test suites. +Jest's configuration object is passed as a parameter to the `globalTeardown` +function. + ### `moduleFileExtensions` [array] Default: `["js", "json", "jsx", "node"]` diff --git a/packages/jest-cli/src/run_jest.js b/packages/jest-cli/src/run_jest.js index f4bd499ddbff..8e685feba623 100644 --- a/packages/jest-cli/src/run_jest.js +++ b/packages/jest-cli/src/run_jest.js @@ -248,7 +248,7 @@ export default (async function runJest({ ); } - await globalSetup(); + await globalSetup(globalConfig); } const results = await new TestScheduler( globalConfig, @@ -271,7 +271,7 @@ export default (async function runJest({ ); } - await globalTeardown(); + await globalTeardown(globalConfig); } return processResults(results, { isJSON: globalConfig.json,