diff --git a/docs/CLI.md b/docs/CLI.md index dfc34da58456..e22c5df733e8 100644 --- a/docs/CLI.md +++ b/docs/CLI.md @@ -290,9 +290,9 @@ Run only the tests that were specified with their exact paths. _Note: The default regex matching works fine on small runs, but becomes slow if provided with multiple patterns and/or against a lot of tests. This option replaces the regex matching logic and by that optimizes the time it takes Jest to filter specific test files_ -### `--setupTestFrameworkScriptFile=` +### `--setupFilesAfterEnv ... ` -The path to a module that runs some code to configure or set up the testing framework before each test. Beware that files imported by the setup script will not be mocked during testing. +A list of paths to modules that run some code to configure or to set up the testing framework before each test. Beware that files imported by the setup scripts will not be mocked during testing. ### `--showConfig` diff --git a/docs/JestObjectAPI.md b/docs/JestObjectAPI.md index 01b177bc598f..4f9c95cab35c 100644 --- a/docs/JestObjectAPI.md +++ b/docs/JestObjectAPI.md @@ -276,7 +276,7 @@ jest.mock( ); ``` -> **Warning:** Importing a module in a setup file (as specified by `setupTestFrameworkScriptFile`) will prevent mocking for the module in question, as well as all the modules that it imports. +> **Warning:** Importing a module in a setup file (as specified by `setupFilesAfterEnv`) will prevent mocking for the module in question, as well as all the modules that it imports. Modules that are mocked with `jest.mock` are mocked only for the file that calls `jest.mock`. Another file that imports the module will get the original implementation even if it runs after the test file that mocks the module. diff --git a/packages/jest-types/src/Config.ts b/packages/jest-types/src/Config.ts index e2967dc9dacc..2108342c9383 100644 --- a/packages/jest-types/src/Config.ts +++ b/packages/jest-types/src/Config.ts @@ -211,6 +211,9 @@ export type InitialOptions = Partial<{ runTestsByPath: boolean; scriptPreprocessor: string; setupFiles: Array; + /** + * @deprecated Use `setupFilesAfterEnv` options instead. + */ setupTestFrameworkScriptFile: Path; setupFilesAfterEnv: Array; silent: boolean; diff --git a/website/versioned_docs/version-25.x/CLI.md b/website/versioned_docs/version-25.x/CLI.md index 18496a6a39a6..156a6f42681c 100644 --- a/website/versioned_docs/version-25.x/CLI.md +++ b/website/versioned_docs/version-25.x/CLI.md @@ -274,9 +274,9 @@ Run only the tests that were specified with their exact paths. _Note: The default regex matching works fine on small runs, but becomes slow if provided with multiple patterns and/or against a lot of tests. This option replaces the regex matching logic and by that optimizes the time it takes Jest to filter specific test files_ -### `--setupTestFrameworkScriptFile=` +### `--setupFilesAfterEnv ... ` -The path to a module that runs some code to configure or set up the testing framework before each test. Beware that files imported by the setup script will not be mocked during testing. +A list of paths to modules that run some code to configure or to set up the testing framework before each test. Beware that files imported by the setup scripts will not be mocked during testing. ### `--showConfig` diff --git a/website/versioned_docs/version-25.x/JestObjectAPI.md b/website/versioned_docs/version-25.x/JestObjectAPI.md index 55a917075757..c13fa986bd6b 100644 --- a/website/versioned_docs/version-25.x/JestObjectAPI.md +++ b/website/versioned_docs/version-25.x/JestObjectAPI.md @@ -272,7 +272,7 @@ jest.mock( ); ``` -> **Warning:** Importing a module in a setup file (as specified by `setupTestFrameworkScriptFile`) will prevent mocking for the module in question, as well as all the modules that it imports. +> **Warning:** Importing a module in a setup file (as specified by `setupFilesAfterEnv`) will prevent mocking for the module in question, as well as all the modules that it imports. Modules that are mocked with `jest.mock` are mocked only for the file that calls `jest.mock`. Another file that imports the module will get the original implementation even if it runs after the test file that mocks the module. diff --git a/website/versioned_docs/version-26.x/CLI.md b/website/versioned_docs/version-26.x/CLI.md index 9efe631523f8..2d4c5fcf389c 100644 --- a/website/versioned_docs/version-26.x/CLI.md +++ b/website/versioned_docs/version-26.x/CLI.md @@ -290,9 +290,9 @@ Run only the tests that were specified with their exact paths. _Note: The default regex matching works fine on small runs, but becomes slow if provided with multiple patterns and/or against a lot of tests. This option replaces the regex matching logic and by that optimizes the time it takes Jest to filter specific test files_ -### `--setupTestFrameworkScriptFile=` +### `--setupFilesAfterEnv ... ` -The path to a module that runs some code to configure or set up the testing framework before each test. Beware that files imported by the setup script will not be mocked during testing. +A list of paths to modules that run some code to configure or to set up the testing framework before each test. Beware that files imported by the setup scripts will not be mocked during testing. ### `--showConfig` diff --git a/website/versioned_docs/version-26.x/Configuration.md b/website/versioned_docs/version-26.x/Configuration.md index 2b9301b42f1b..fdf5b8aaf8c9 100644 --- a/website/versioned_docs/version-26.x/Configuration.md +++ b/website/versioned_docs/version-26.x/Configuration.md @@ -898,8 +898,6 @@ If you want a path to be [relative to the root directory of your project](#rootd For example, Jest ships with several plug-ins to `jasmine` that work by monkey-patching the jasmine API. If you wanted to add even more jasmine plugins to the mix (or if you wanted some custom, project-wide matchers for example), you could do so in these modules. -_Note: `setupTestFrameworkScriptFile` is deprecated in favor of `setupFilesAfterEnv`._ - Example `setupFilesAfterEnv` array in a jest.config.js: ```js diff --git a/website/versioned_docs/version-26.x/JestObjectAPI.md b/website/versioned_docs/version-26.x/JestObjectAPI.md index d1a2f1ec15f3..e7d8808d33c8 100644 --- a/website/versioned_docs/version-26.x/JestObjectAPI.md +++ b/website/versioned_docs/version-26.x/JestObjectAPI.md @@ -276,7 +276,7 @@ jest.mock( ); ``` -> **Warning:** Importing a module in a setup file (as specified by `setupTestFrameworkScriptFile`) will prevent mocking for the module in question, as well as all the modules that it imports. +> **Warning:** Importing a module in a setup file (as specified by `setupFilesAfterEnv`) will prevent mocking for the module in question, as well as all the modules that it imports. Modules that are mocked with `jest.mock` are mocked only for the file that calls `jest.mock`. Another file that imports the module will get the original implementation even if it runs after the test file that mocks the module. diff --git a/website/versioned_docs/version-27.0/CLI.md b/website/versioned_docs/version-27.0/CLI.md index 4479ccb8e180..437254712a87 100644 --- a/website/versioned_docs/version-27.0/CLI.md +++ b/website/versioned_docs/version-27.0/CLI.md @@ -290,9 +290,9 @@ Run only the tests that were specified with their exact paths. _Note: The default regex matching works fine on small runs, but becomes slow if provided with multiple patterns and/or against a lot of tests. This option replaces the regex matching logic and by that optimizes the time it takes Jest to filter specific test files_ -### `--setupTestFrameworkScriptFile=` +### `--setupFilesAfterEnv ... ` -The path to a module that runs some code to configure or set up the testing framework before each test. Beware that files imported by the setup script will not be mocked during testing. +A list of paths to modules that run some code to configure or to set up the testing framework before each test. Beware that files imported by the setup scripts will not be mocked during testing. ### `--showConfig` diff --git a/website/versioned_docs/version-27.0/Configuration.md b/website/versioned_docs/version-27.0/Configuration.md index ad0251a572ca..6a3f6f66cb96 100644 --- a/website/versioned_docs/version-27.0/Configuration.md +++ b/website/versioned_docs/version-27.0/Configuration.md @@ -925,8 +925,6 @@ If you want a path to be [relative to the root directory of your project](#rootd For example, Jest ships with several plug-ins to `jasmine` that work by monkey-patching the jasmine API. If you wanted to add even more jasmine plugins to the mix (or if you wanted some custom, project-wide matchers for example), you could do so in these modules. -_Note: `setupTestFrameworkScriptFile` is deprecated in favor of `setupFilesAfterEnv`._ - Example `setupFilesAfterEnv` array in a jest.config.js: ```js diff --git a/website/versioned_docs/version-27.0/JestObjectAPI.md b/website/versioned_docs/version-27.0/JestObjectAPI.md index 01b177bc598f..4f9c95cab35c 100644 --- a/website/versioned_docs/version-27.0/JestObjectAPI.md +++ b/website/versioned_docs/version-27.0/JestObjectAPI.md @@ -276,7 +276,7 @@ jest.mock( ); ``` -> **Warning:** Importing a module in a setup file (as specified by `setupTestFrameworkScriptFile`) will prevent mocking for the module in question, as well as all the modules that it imports. +> **Warning:** Importing a module in a setup file (as specified by `setupFilesAfterEnv`) will prevent mocking for the module in question, as well as all the modules that it imports. Modules that are mocked with `jest.mock` are mocked only for the file that calls `jest.mock`. Another file that imports the module will get the original implementation even if it runs after the test file that mocks the module. diff --git a/website/versioned_docs/version-27.1/CLI.md b/website/versioned_docs/version-27.1/CLI.md index 4479ccb8e180..437254712a87 100644 --- a/website/versioned_docs/version-27.1/CLI.md +++ b/website/versioned_docs/version-27.1/CLI.md @@ -290,9 +290,9 @@ Run only the tests that were specified with their exact paths. _Note: The default regex matching works fine on small runs, but becomes slow if provided with multiple patterns and/or against a lot of tests. This option replaces the regex matching logic and by that optimizes the time it takes Jest to filter specific test files_ -### `--setupTestFrameworkScriptFile=` +### `--setupFilesAfterEnv ... ` -The path to a module that runs some code to configure or set up the testing framework before each test. Beware that files imported by the setup script will not be mocked during testing. +A list of paths to modules that run some code to configure or to set up the testing framework before each test. Beware that files imported by the setup scripts will not be mocked during testing. ### `--showConfig` diff --git a/website/versioned_docs/version-27.1/Configuration.md b/website/versioned_docs/version-27.1/Configuration.md index 5edc798578e2..6e72e76cbb70 100644 --- a/website/versioned_docs/version-27.1/Configuration.md +++ b/website/versioned_docs/version-27.1/Configuration.md @@ -925,8 +925,6 @@ If you want a path to be [relative to the root directory of your project](#rootd For example, Jest ships with several plug-ins to `jasmine` that work by monkey-patching the jasmine API. If you wanted to add even more jasmine plugins to the mix (or if you wanted some custom, project-wide matchers for example), you could do so in these modules. -_Note: `setupTestFrameworkScriptFile` is deprecated in favor of `setupFilesAfterEnv`._ - Example `setupFilesAfterEnv` array in a jest.config.js: ```js diff --git a/website/versioned_docs/version-27.1/JestObjectAPI.md b/website/versioned_docs/version-27.1/JestObjectAPI.md index 01b177bc598f..4f9c95cab35c 100644 --- a/website/versioned_docs/version-27.1/JestObjectAPI.md +++ b/website/versioned_docs/version-27.1/JestObjectAPI.md @@ -276,7 +276,7 @@ jest.mock( ); ``` -> **Warning:** Importing a module in a setup file (as specified by `setupTestFrameworkScriptFile`) will prevent mocking for the module in question, as well as all the modules that it imports. +> **Warning:** Importing a module in a setup file (as specified by `setupFilesAfterEnv`) will prevent mocking for the module in question, as well as all the modules that it imports. Modules that are mocked with `jest.mock` are mocked only for the file that calls `jest.mock`. Another file that imports the module will get the original implementation even if it runs after the test file that mocks the module. diff --git a/website/versioned_docs/version-27.2/CLI.md b/website/versioned_docs/version-27.2/CLI.md index dfc34da58456..e22c5df733e8 100644 --- a/website/versioned_docs/version-27.2/CLI.md +++ b/website/versioned_docs/version-27.2/CLI.md @@ -290,9 +290,9 @@ Run only the tests that were specified with their exact paths. _Note: The default regex matching works fine on small runs, but becomes slow if provided with multiple patterns and/or against a lot of tests. This option replaces the regex matching logic and by that optimizes the time it takes Jest to filter specific test files_ -### `--setupTestFrameworkScriptFile=` +### `--setupFilesAfterEnv ... ` -The path to a module that runs some code to configure or set up the testing framework before each test. Beware that files imported by the setup script will not be mocked during testing. +A list of paths to modules that run some code to configure or to set up the testing framework before each test. Beware that files imported by the setup scripts will not be mocked during testing. ### `--showConfig` diff --git a/website/versioned_docs/version-27.2/Configuration.md b/website/versioned_docs/version-27.2/Configuration.md index 5b051f3ff450..d5c9bc73328c 100644 --- a/website/versioned_docs/version-27.2/Configuration.md +++ b/website/versioned_docs/version-27.2/Configuration.md @@ -929,8 +929,6 @@ If you want a path to be [relative to the root directory of your project](#rootd For example, Jest ships with several plug-ins to `jasmine` that work by monkey-patching the jasmine API. If you wanted to add even more jasmine plugins to the mix (or if you wanted some custom, project-wide matchers for example), you could do so in these modules. -_Note: `setupTestFrameworkScriptFile` is deprecated in favor of `setupFilesAfterEnv`._ - Example `setupFilesAfterEnv` array in a jest.config.js: ```js diff --git a/website/versioned_docs/version-27.2/JestObjectAPI.md b/website/versioned_docs/version-27.2/JestObjectAPI.md index 01b177bc598f..4f9c95cab35c 100644 --- a/website/versioned_docs/version-27.2/JestObjectAPI.md +++ b/website/versioned_docs/version-27.2/JestObjectAPI.md @@ -276,7 +276,7 @@ jest.mock( ); ``` -> **Warning:** Importing a module in a setup file (as specified by `setupTestFrameworkScriptFile`) will prevent mocking for the module in question, as well as all the modules that it imports. +> **Warning:** Importing a module in a setup file (as specified by `setupFilesAfterEnv`) will prevent mocking for the module in question, as well as all the modules that it imports. Modules that are mocked with `jest.mock` are mocked only for the file that calls `jest.mock`. Another file that imports the module will get the original implementation even if it runs after the test file that mocks the module.