From 5b3cf011b7bbac5f28bfde9ae1896d1c2844ab85 Mon Sep 17 00:00:00 2001 From: John Carmichael Date: Sat, 21 Sep 2019 19:54:11 +0200 Subject: [PATCH 1/5] docs: setupFilesAfterEnv arr expansion and updated reference in JestObjectApi --- docs/Configuration.md | 14 ++++++++++++++ docs/JestObjectAPI.md | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/docs/Configuration.md b/docs/Configuration.md index 85ec47c164d4..32186fad0284 100644 --- a/docs/Configuration.md +++ b/docs/Configuration.md @@ -754,6 +754,20 @@ 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: ['./setup.js'], +} +``` + +Example `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..81ac9eab768a 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: 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 `jest.config` with `setupFilesAfterEnv`._ Example: From df16b32fb68e798043dd8d50c07b89d5b48f1ddd Mon Sep 17 00:00:00 2001 From: John Carmichael Date: Sat, 21 Sep 2019 20:09:40 +0200 Subject: [PATCH 2/5] docs: latest pr added to changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c020577ef04b..a4ef010d5ed3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -49,6 +49,7 @@ - `[jest-environment-jsdom]` [**BREAKING**] Upgrade JSDOM from v11 to v15 ([#8851](https://github.com/facebook/jest/pull/8851)) - `[jest-util]` [**BREAKING**] Remove deprecated exports ([#8863](https://github.com/facebook/jest/pull/8863)) - `[jest-validate]` [**BREAKING**] Use ESM exports ([#8874](https://github.com/facebook/jest/pull/8874)) +- `[docs]` setupFilesAfterEnv arr expansion and updated reference in JestObjectApi ([#8824](https://github.com/facebook/jest/pull/8971)) ### Performance From 0f6871687b35a47152149700281ffa762488337c Mon Sep 17 00:00:00 2001 From: John Carmichael Date: Sat, 21 Sep 2019 20:21:03 +0200 Subject: [PATCH 3/5] docs: Configuration naming convention from setup to jest.setup --- docs/Configuration.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/Configuration.md b/docs/Configuration.md index 32186fad0284..88261654e742 100644 --- a/docs/Configuration.md +++ b/docs/Configuration.md @@ -758,11 +758,11 @@ Example `setupFilesAfterEnv` array in a jest.config.js: ```js module.exports = { - setupFilesAfterEnv: ['./setup.js'], + setupFilesAfterEnv: ['./jest.setup.js'], } ``` -Example `setup.js` file +Example `jest.setup.js` file ```js jest.setTimeout(10000); // in milliseconds ``` From 08fd37d98619c2f8dd64bfa4d6a11f73c766a34f Mon Sep 17 00:00:00 2001 From: John Carmichael Date: Sun, 22 Sep 2019 09:35:44 +0200 Subject: [PATCH 4/5] docs: Tweaking timeout docs to better explain when it can be applied universally --- docs/JestObjectAPI.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/JestObjectAPI.md b/docs/JestObjectAPI.md index 81ac9eab768a..cb75a5d0eed4 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 `jest.config` with `setupFilesAfterEnv`._ +_Note: A good place to do this to increase all timeouts before all tests are run is with `setupFilesAfterEnv`._ Example: From 28967d1bc0ebc16401ea1854da0590f680367f8f Mon Sep 17 00:00:00 2001 From: Tim Seckinger Date: Sun, 22 Sep 2019 12:28:25 +0200 Subject: [PATCH 5/5] cleanup --- CHANGELOG.md | 2 +- docs/Configuration.md | 1 - docs/JestObjectAPI.md | 2 +- .../versioned_docs/version-22.x/JestObjectAPI.md | 2 +- .../versioned_docs/version-23.x/JestObjectAPI.md | 2 +- .../versioned_docs/version-24.0/Configuration.md | 13 +++++++++++++ .../versioned_docs/version-24.0/JestObjectAPI.md | 2 +- .../versioned_docs/version-24.1/Configuration.md | 13 +++++++++++++ .../versioned_docs/version-24.6/Configuration.md | 13 +++++++++++++ .../versioned_docs/version-24.8/Configuration.md | 13 +++++++++++++ .../versioned_docs/version-24.9/Configuration.md | 13 +++++++++++++ .../versioned_docs/version-24.9/JestObjectAPI.md | 2 +- 12 files changed, 71 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a4ef010d5ed3..022beb6b2b97 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -43,13 +43,13 @@ - `[*]` [**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)) - `[jest-environment-jsdom]` [**BREAKING**] Upgrade JSDOM from v11 to v15 ([#8851](https://github.com/facebook/jest/pull/8851)) - `[jest-util]` [**BREAKING**] Remove deprecated exports ([#8863](https://github.com/facebook/jest/pull/8863)) - `[jest-validate]` [**BREAKING**] Use ESM exports ([#8874](https://github.com/facebook/jest/pull/8874)) -- `[docs]` setupFilesAfterEnv arr expansion and updated reference in JestObjectApi ([#8824](https://github.com/facebook/jest/pull/8971)) ### Performance diff --git a/docs/Configuration.md b/docs/Configuration.md index 88261654e742..6e03ff749b23 100644 --- a/docs/Configuration.md +++ b/docs/Configuration.md @@ -767,7 +767,6 @@ Example `jest.setup.js` file jest.setTimeout(10000); // in milliseconds ``` - ### `snapshotResolver` [string] Default: `undefined` diff --git a/docs/JestObjectAPI.md b/docs/JestObjectAPI.md index cb75a5d0eed4..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: A good place to do this to increase all timeouts before all tests are run is with `setupFilesAfterEnv`._ +_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: