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

Updated run to pass globalSetup and globalTeardown configuration #5961

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all 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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 6 additions & 0 deletions docs/Configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -358,13 +358,19 @@ 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`

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`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not, strictly speaking, Jest configuration. It's a part of config, that's responsible for globally available options, for every project out there. I think we should make it clear and link e.g. to type definition.

function.

### `moduleFileExtensions` [array<string>]

Default: `["js", "json", "jsx", "node"]`
Expand Down
4 changes: 2 additions & 2 deletions packages/jest-cli/src/run_jest.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ export default (async function runJest({
);
}

await globalSetup();
await globalSetup(globalConfig);
}
const results = await new TestScheduler(
globalConfig,
Expand All @@ -271,7 +271,7 @@ export default (async function runJest({
);
}

await globalTeardown();
await globalTeardown(globalConfig);
}
return processResults(results, {
isJSON: globalConfig.json,
Expand Down