diff --git a/docs/Configuration.md b/docs/Configuration.md index 585910460707..9a2605816768 100644 --- a/docs/Configuration.md +++ b/docs/Configuration.md @@ -1012,6 +1012,14 @@ The class may optionally expose an asynchronous `handleTestEvent` method to bind Any docblock pragmas in test files will be passed to the environment constructor and can be used for per-test configuration. If the pragma does not have a value, it will be present in the object with its value set to an empty string. If the pragma is not present, it will not be present in the object. +To use this class as your custom environment, refer to it by its full path within the project. For example, if your class is stored in `my-custom-environment.js` in some subfolder of your project, then the annotation might looke like this: + +```js +/** + * @jest-environment ./src/test/my-custom-environment + */ +``` + _Note: TestEnvironment is sandboxed. Each test suite will trigger setup/teardown in their own TestEnvironment._ Example: @@ -1060,6 +1068,9 @@ module.exports = CustomEnvironment; ```js // my-test-suite +/** + * @jest-environment ./my-custom-environment + */ let someGlobalObject; beforeAll(() => { diff --git a/website/versioned_docs/version-22.x/Configuration.md b/website/versioned_docs/version-22.x/Configuration.md index ab474ab74fe9..6a60435e2daf 100644 --- a/website/versioned_docs/version-22.x/Configuration.md +++ b/website/versioned_docs/version-22.x/Configuration.md @@ -745,6 +745,14 @@ test('use jsdom in this test file', () => { You can create your own module that will be used for setting up the test environment. The module must export a class with `setup`, `teardown` and `runScript` methods. You can also pass variables from this module to your test suites by assigning them to `this.global` object – this will make them available in your test suites as global variables. +To use this class as your custom environment, refer to it by its full path within the project. For example, if your class is stored in `my-custom-environment.js` in some subfolder of your project, then the annotation might looke like this: + +```js +/** + * @jest-environment ./src/test/my-custom-environment + */ +``` + _Note: TestEnvironment is sandboxed. Each test suite will trigger setup/teardown in their own TestEnvironment._ Example: @@ -787,6 +795,9 @@ module.exports = CustomEnvironment; ```js // my-test-suite +/** + * @jest-environment ./my-custom-environment + */ let someGlobalObject; beforeAll(() => { diff --git a/website/versioned_docs/version-23.x/Configuration.md b/website/versioned_docs/version-23.x/Configuration.md index 6741c6c7f5ff..ff74ed3a6c9b 100644 --- a/website/versioned_docs/version-23.x/Configuration.md +++ b/website/versioned_docs/version-23.x/Configuration.md @@ -771,6 +771,14 @@ test('use jsdom in this test file', () => { You can create your own module that will be used for setting up the test environment. The module must export a class with `setup`, `teardown` and `runScript` methods. You can also pass variables from this module to your test suites by assigning them to `this.global` object – this will make them available in your test suites as global variables. +To use this class as your custom environment, refer to it by its full path within the project. For example, if your class is stored in `my-custom-environment.js` in some subfolder of your project, then the annotation might looke like this: + +```js +/** + * @jest-environment ./src/test/my-custom-environment + */ +``` + _Note: TestEnvironment is sandboxed. Each test suite will trigger setup/teardown in their own TestEnvironment._ Example: @@ -813,6 +821,9 @@ module.exports = CustomEnvironment; ```js // my-test-suite +/** + * @jest-environment ./my-custom-environment + */ let someGlobalObject; beforeAll(() => { diff --git a/website/versioned_docs/version-24.x/Configuration.md b/website/versioned_docs/version-24.x/Configuration.md index b97929c4203c..1980041c25ac 100644 --- a/website/versioned_docs/version-24.x/Configuration.md +++ b/website/versioned_docs/version-24.x/Configuration.md @@ -906,6 +906,14 @@ The class may optionally expose a `handleTestEvent` method to bind to events fir Any docblock pragmas in test files will be passed to the environment constructor and can be used for per-test configuration. If the pragma does not have a value, it will be present in the object with its value set to an empty string. If the pragma is not present, it will not be present in the object. +To use this class as your custom environment, refer to it by its full path within the project. For example, if your class is stored in `my-custom-environment.js` in some subfolder of your project, then the annotation might looke like this: + +```js +/** + * @jest-environment ./src/test/my-custom-environment + */ +``` + _Note: TestEnvironment is sandboxed. Each test suite will trigger setup/teardown in their own TestEnvironment._ Example: @@ -954,6 +962,9 @@ module.exports = CustomEnvironment; ```js // my-test-suite +/** + * @jest-environment ./my-custom-environment + */ let someGlobalObject; beforeAll(() => { diff --git a/website/versioned_docs/version-25.x/Configuration.md b/website/versioned_docs/version-25.x/Configuration.md index 92bb10dc1b6d..fc13931cf58c 100644 --- a/website/versioned_docs/version-25.x/Configuration.md +++ b/website/versioned_docs/version-25.x/Configuration.md @@ -930,6 +930,14 @@ The class may optionally expose an asynchronous `handleTestEvent` method to bind Any docblock pragmas in test files will be passed to the environment constructor and can be used for per-test configuration. If the pragma does not have a value, it will be present in the object with its value set to an empty string. If the pragma is not present, it will not be present in the object. +To use this class as your custom environment, refer to it by its full path within the project. For example, if your class is stored in `my-custom-environment.js` in some subfolder of your project, then the annotation might looke like this: + +```js +/** + * @jest-environment ./src/test/my-custom-environment + */ +``` + _Note: TestEnvironment is sandboxed. Each test suite will trigger setup/teardown in their own TestEnvironment._ Example: @@ -978,6 +986,9 @@ module.exports = CustomEnvironment; ```js // my-test-suite +/** + * @jest-environment ./my-custom-environment + */ let someGlobalObject; beforeAll(() => { diff --git a/website/versioned_docs/version-26.0/Configuration.md b/website/versioned_docs/version-26.0/Configuration.md index 8f3191c1ee40..068de2987fea 100644 --- a/website/versioned_docs/version-26.0/Configuration.md +++ b/website/versioned_docs/version-26.0/Configuration.md @@ -930,6 +930,14 @@ The class may optionally expose an asynchronous `handleTestEvent` method to bind Any docblock pragmas in test files will be passed to the environment constructor and can be used for per-test configuration. If the pragma does not have a value, it will be present in the object with its value set to an empty string. If the pragma is not present, it will not be present in the object. +To use this class as your custom environment, refer to it by its full path within the project. For example, if your class is stored in `my-custom-environment.js` in some subfolder of your project, then the annotation might looke like this: + +```js +/** + * @jest-environment ./src/test/my-custom-environment + */ +``` + _Note: TestEnvironment is sandboxed. Each test suite will trigger setup/teardown in their own TestEnvironment._ Example: @@ -978,6 +986,9 @@ module.exports = CustomEnvironment; ```js // my-test-suite +/** + * @jest-environment ./my-custom-environment + */ let someGlobalObject; beforeAll(() => { diff --git a/website/versioned_docs/version-26.2/Configuration.md b/website/versioned_docs/version-26.2/Configuration.md index ab36e57ea5f0..6a604b00d6f6 100644 --- a/website/versioned_docs/version-26.2/Configuration.md +++ b/website/versioned_docs/version-26.2/Configuration.md @@ -944,6 +944,14 @@ The class may optionally expose an asynchronous `handleTestEvent` method to bind Any docblock pragmas in test files will be passed to the environment constructor and can be used for per-test configuration. If the pragma does not have a value, it will be present in the object with its value set to an empty string. If the pragma is not present, it will not be present in the object. +To use this class as your custom environment, refer to it by its full path within the project. For example, if your class is stored in `my-custom-environment.js` in some subfolder of your project, then the annotation might looke like this: + +```js +/** + * @jest-environment ./src/test/my-custom-environment + */ +``` + _Note: TestEnvironment is sandboxed. Each test suite will trigger setup/teardown in their own TestEnvironment._ Example: @@ -992,6 +1000,9 @@ module.exports = CustomEnvironment; ```js // my-test-suite +/** + * @jest-environment ./my-custom-environment + */ let someGlobalObject; beforeAll(() => { diff --git a/website/versioned_docs/version-26.4/Configuration.md b/website/versioned_docs/version-26.4/Configuration.md index be09c78c9488..8f485c9149ff 100644 --- a/website/versioned_docs/version-26.4/Configuration.md +++ b/website/versioned_docs/version-26.4/Configuration.md @@ -975,6 +975,14 @@ The class may optionally expose an asynchronous `handleTestEvent` method to bind Any docblock pragmas in test files will be passed to the environment constructor and can be used for per-test configuration. If the pragma does not have a value, it will be present in the object with its value set to an empty string. If the pragma is not present, it will not be present in the object. +To use this class as your custom environment, refer to it by its full path within the project. For example, if your class is stored in `my-custom-environment.js` in some subfolder of your project, then the annotation might looke like this: + +```js +/** + * @jest-environment ./src/test/my-custom-environment + */ +``` + _Note: TestEnvironment is sandboxed. Each test suite will trigger setup/teardown in their own TestEnvironment._ Example: @@ -1023,6 +1031,9 @@ module.exports = CustomEnvironment; ```js // my-test-suite +/** + * @jest-environment ./my-custom-environment + */ let someGlobalObject; beforeAll(() => { diff --git a/website/versioned_docs/version-26.5/Configuration.md b/website/versioned_docs/version-26.5/Configuration.md index bf1b373778f3..9ddbbd9ca9ff 100644 --- a/website/versioned_docs/version-26.5/Configuration.md +++ b/website/versioned_docs/version-26.5/Configuration.md @@ -993,6 +993,14 @@ The class may optionally expose an asynchronous `handleTestEvent` method to bind Any docblock pragmas in test files will be passed to the environment constructor and can be used for per-test configuration. If the pragma does not have a value, it will be present in the object with its value set to an empty string. If the pragma is not present, it will not be present in the object. +To use this class as your custom environment, refer to it by its full path within the project. For example, if your class is stored in `my-custom-environment.js` in some subfolder of your project, then the annotation might looke like this: + +```js +/** + * @jest-environment ./src/test/my-custom-environment + */ +``` + _Note: TestEnvironment is sandboxed. Each test suite will trigger setup/teardown in their own TestEnvironment._ Example: @@ -1041,6 +1049,9 @@ module.exports = CustomEnvironment; ```js // my-test-suite +/** + * @jest-environment ./my-custom-environment + */ let someGlobalObject; beforeAll(() => { diff --git a/website/versioned_docs/version-26.6/Configuration.md b/website/versioned_docs/version-26.6/Configuration.md index 9464544a8b1d..c309eb22a005 100644 --- a/website/versioned_docs/version-26.6/Configuration.md +++ b/website/versioned_docs/version-26.6/Configuration.md @@ -1013,6 +1013,14 @@ The class may optionally expose an asynchronous `handleTestEvent` method to bind Any docblock pragmas in test files will be passed to the environment constructor and can be used for per-test configuration. If the pragma does not have a value, it will be present in the object with its value set to an empty string. If the pragma is not present, it will not be present in the object. +To use this class as your custom environment, refer to it by its full path within the project. For example, if your class is stored in `my-custom-environment.js` in some subfolder of your project, then the annotation might looke like this: + +```js +/** + * @jest-environment ./src/test/my-custom-environment + */ +``` + _Note: TestEnvironment is sandboxed. Each test suite will trigger setup/teardown in their own TestEnvironment._ Example: @@ -1061,6 +1069,9 @@ module.exports = CustomEnvironment; ```js // my-test-suite +/** + * @jest-environment ./my-custom-environment + */ let someGlobalObject; beforeAll(() => {