diff --git a/CHANGELOG.md b/CHANGELOG.md index 8d7e33a102ee..c1bf053cde4a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -44,6 +44,7 @@ - `[*]` [**BREAKING**] Upgrade to Micromatch v4 ([#8852](https://github.com/facebook/jest/pull/8852)) - `[babel-plugin-jest-hoist]` [**BREAKING**] Use ESM exports ([#8874](https://github.com/facebook/jest/pull/8874)) - `[docs]` Fix broken link pointing to legacy JS file in "Snapshot Testing". +- `[docs]` Add `setupFilesAfterEnv` and `jest.setTimeout` example ([#8971](https://github.com/facebook/jest/pull/8971)) - `[jest]` [**BREAKING**] Use ESM exports ([#8874](https://github.com/facebook/jest/pull/8874)) - `[jest-cli]` [**BREAKING**] Use ESM exports ([#8874](https://github.com/facebook/jest/pull/8874)) - `[jest-cli]` [**BREAKING**] Remove re-exports from `@jest/core` ([#8874](https://github.com/facebook/jest/pull/8874)) diff --git a/docs/Configuration.md b/docs/Configuration.md index 85ec47c164d4..6e03ff749b23 100644 --- a/docs/Configuration.md +++ b/docs/Configuration.md @@ -754,6 +754,19 @@ For example, Jest ships with several plug-ins to `jasmine` that work by monkey-p _Note: `setupTestFrameworkScriptFile` is deprecated in favor of `setupFilesAfterEnv`._ +Example `setupFilesAfterEnv` array in a jest.config.js: + +```js +module.exports = { + setupFilesAfterEnv: ['./jest.setup.js'], +} +``` + +Example `jest.setup.js` file +```js +jest.setTimeout(10000); // in milliseconds +``` + ### `snapshotResolver` [string] Default: `undefined` diff --git a/docs/JestObjectAPI.md b/docs/JestObjectAPI.md index 6919fcb905f6..66a6aac0e645 100644 --- a/docs/JestObjectAPI.md +++ b/docs/JestObjectAPI.md @@ -647,7 +647,7 @@ Set the default timeout interval for tests and before/after hooks in millisecond _Note: The default timeout interval is 5 seconds if this method is not called._ -_Note: The method must be called after the test framework is installed in the environment and before the test runs. A good place to do this is in the `setupTestFrameworkScriptFile`._ +_Note: If you want to set the timeout for all test files, a good place to do this is in `setupFilesAfterEnv`._ Example: diff --git a/website/versioned_docs/version-22.x/JestObjectAPI.md b/website/versioned_docs/version-22.x/JestObjectAPI.md index 576548e9828b..899bfc399285 100644 --- a/website/versioned_docs/version-22.x/JestObjectAPI.md +++ b/website/versioned_docs/version-22.x/JestObjectAPI.md @@ -542,7 +542,7 @@ Set the default timeout interval for tests and before/after hooks in millisecond _Note: The default timeout interval is 5 seconds if this method is not called._ -_Note: The method must be called after the test framework is installed in the environment and before the test runs. A good place to do this is in the `setupTestFrameworkScriptFile`._ +_Note: If you want to set the timeout for all test files, a good place to do this is in `setupFilesAfterEnv`._ Example: diff --git a/website/versioned_docs/version-23.x/JestObjectAPI.md b/website/versioned_docs/version-23.x/JestObjectAPI.md index 854bae59aaf4..050344bc0463 100644 --- a/website/versioned_docs/version-23.x/JestObjectAPI.md +++ b/website/versioned_docs/version-23.x/JestObjectAPI.md @@ -558,7 +558,7 @@ Set the default timeout interval for tests and before/after hooks in millisecond _Note: The default timeout interval is 5 seconds if this method is not called._ -_Note: The method must be called after the test framework is installed in the environment and before the test runs. A good place to do this is in the `setupTestFrameworkScriptFile`._ +_Note: If you want to set the timeout for all test files, a good place to do this is in `setupFilesAfterEnv`._ Example: diff --git a/website/versioned_docs/version-24.0/Configuration.md b/website/versioned_docs/version-24.0/Configuration.md index 9a1727bf45a3..545d3d284c24 100644 --- a/website/versioned_docs/version-24.0/Configuration.md +++ b/website/versioned_docs/version-24.0/Configuration.md @@ -727,6 +727,19 @@ For example, Jest ships with several plug-ins to `jasmine` that work by monkey-p _Note: `setupTestFrameworkScriptFile` is deprecated in favor of `setupFilesAfterEnv`._ +Example `setupFilesAfterEnv` array in a jest.config.js: + +```js +module.exports = { + setupFilesAfterEnv: ['./jest.setup.js'], +} +``` + +Example `jest.setup.js` file +```js +jest.setTimeout(10000); // in milliseconds +``` + ### `snapshotResolver` [string] Default: `undefined` diff --git a/website/versioned_docs/version-24.0/JestObjectAPI.md b/website/versioned_docs/version-24.0/JestObjectAPI.md index 7a526f687c49..9e4ed5a90280 100644 --- a/website/versioned_docs/version-24.0/JestObjectAPI.md +++ b/website/versioned_docs/version-24.0/JestObjectAPI.md @@ -642,7 +642,7 @@ Set the default timeout interval for tests and before/after hooks in millisecond _Note: The default timeout interval is 5 seconds if this method is not called._ -_Note: The method must be called after the test framework is installed in the environment and before the test runs. A good place to do this is in the `setupTestFrameworkScriptFile`._ +_Note: If you want to set the timeout for all test files, a good place to do this is in `setupFilesAfterEnv`._ Example: diff --git a/website/versioned_docs/version-24.1/Configuration.md b/website/versioned_docs/version-24.1/Configuration.md index fe5f2697497a..b28af46f47bd 100644 --- a/website/versioned_docs/version-24.1/Configuration.md +++ b/website/versioned_docs/version-24.1/Configuration.md @@ -736,6 +736,19 @@ For example, Jest ships with several plug-ins to `jasmine` that work by monkey-p _Note: `setupTestFrameworkScriptFile` is deprecated in favor of `setupFilesAfterEnv`._ +Example `setupFilesAfterEnv` array in a jest.config.js: + +```js +module.exports = { + setupFilesAfterEnv: ['./jest.setup.js'], +} +``` + +Example `jest.setup.js` file +```js +jest.setTimeout(10000); // in milliseconds +``` + ### `snapshotResolver` [string] Default: `undefined` diff --git a/website/versioned_docs/version-24.6/Configuration.md b/website/versioned_docs/version-24.6/Configuration.md index 0eb0f5c27eba..0997f5fe5e23 100644 --- a/website/versioned_docs/version-24.6/Configuration.md +++ b/website/versioned_docs/version-24.6/Configuration.md @@ -755,6 +755,19 @@ For example, Jest ships with several plug-ins to `jasmine` that work by monkey-p _Note: `setupTestFrameworkScriptFile` is deprecated in favor of `setupFilesAfterEnv`._ +Example `setupFilesAfterEnv` array in a jest.config.js: + +```js +module.exports = { + setupFilesAfterEnv: ['./jest.setup.js'], +} +``` + +Example `jest.setup.js` file +```js +jest.setTimeout(10000); // in milliseconds +``` + ### `snapshotResolver` [string] Default: `undefined` diff --git a/website/versioned_docs/version-24.8/Configuration.md b/website/versioned_docs/version-24.8/Configuration.md index efde4119d638..5faa85fd3b8a 100644 --- a/website/versioned_docs/version-24.8/Configuration.md +++ b/website/versioned_docs/version-24.8/Configuration.md @@ -755,6 +755,19 @@ For example, Jest ships with several plug-ins to `jasmine` that work by monkey-p _Note: `setupTestFrameworkScriptFile` is deprecated in favor of `setupFilesAfterEnv`._ +Example `setupFilesAfterEnv` array in a jest.config.js: + +```js +module.exports = { + setupFilesAfterEnv: ['./jest.setup.js'], +} +``` + +Example `jest.setup.js` file +```js +jest.setTimeout(10000); // in milliseconds +``` + ### `snapshotResolver` [string] Default: `undefined` diff --git a/website/versioned_docs/version-24.9/Configuration.md b/website/versioned_docs/version-24.9/Configuration.md index b271b512fceb..3e4ec1bca240 100644 --- a/website/versioned_docs/version-24.9/Configuration.md +++ b/website/versioned_docs/version-24.9/Configuration.md @@ -755,6 +755,19 @@ For example, Jest ships with several plug-ins to `jasmine` that work by monkey-p _Note: `setupTestFrameworkScriptFile` is deprecated in favor of `setupFilesAfterEnv`._ +Example `setupFilesAfterEnv` array in a jest.config.js: + +```js +module.exports = { + setupFilesAfterEnv: ['./jest.setup.js'], +} +``` + +Example `jest.setup.js` file +```js +jest.setTimeout(10000); // in milliseconds +``` + ### `snapshotResolver` [string] Default: `undefined` diff --git a/website/versioned_docs/version-24.9/JestObjectAPI.md b/website/versioned_docs/version-24.9/JestObjectAPI.md index ea45b871e780..587be011b8c6 100644 --- a/website/versioned_docs/version-24.9/JestObjectAPI.md +++ b/website/versioned_docs/version-24.9/JestObjectAPI.md @@ -648,7 +648,7 @@ Set the default timeout interval for tests and before/after hooks in millisecond _Note: The default timeout interval is 5 seconds if this method is not called._ -_Note: The method must be called after the test framework is installed in the environment and before the test runs. A good place to do this is in the `setupTestFrameworkScriptFile`._ +_Note: If you want to set the timeout for all test files, a good place to do this is in `setupFilesAfterEnv`._ Example: