Skip to content

Commit

Permalink
docs: add missing admonitions in configuration page v29 (#13908)
Browse files Browse the repository at this point in the history
  • Loading branch information
mrazauskas committed Feb 15, 2023
1 parent 267fdbe commit c72962c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
16 changes: 12 additions & 4 deletions website/versioned_docs/version-29.0/Configuration.md
Expand Up @@ -762,7 +762,11 @@ const config: Config = {
export default config;
```

Note that, if you specify a global reference value (like an object or array) here, and some code mutates that value in the midst of running a test, that mutation will _not_ be persisted across test runs for other test files. In addition, the `globals` object must be json-serializable, so it can't be used to specify global functions. For that, you should use `setupFiles`.
:::note

If you specify a global reference value (like an object or array) here, and some code mutates that value in the midst of running a test, that mutation will _not_ be persisted across test runs for other test files. In addition, the `globals` object must be json-serializable, so it can't be used to specify global functions. For that, you should use `setupFiles`.

:::

### `globalSetup` \[string]

Expand Down Expand Up @@ -1124,7 +1128,7 @@ export default config;

:::info

Note that if you also have specified [`rootDir`](#rootdir-string) that the resolution of this file will be relative to that root directory.
If you also have specified [`rootDir`](#rootdir-string), the resolution of this file will be relative to that root directory.

:::

Expand Down Expand Up @@ -1752,10 +1756,14 @@ Pretty foo: Object {
}
```

:::tip

To make a dependency explicit instead of implicit, you can call [`expect.addSnapshotSerializer`](ExpectAPI.md#expectaddsnapshotserializerserializer) to add a module for an individual test file instead of adding its path to `snapshotSerializers` in Jest configuration.

More about serializers API can be found [here](https://github.com/facebook/jest/tree/main/packages/pretty-format/README.md#serialize).

:::

### `testEnvironment` \[string]

Default: `"node"`
Expand Down Expand Up @@ -1863,7 +1871,7 @@ For example, in `jest-environment-jsdom`, you can override options given to [`js

Both `jest-environment-jsdom` and `jest-environment-node` allow specifying `customExportConditions`, which allow you to control which versions of a library are loaded from `exports` in `package.json`. `jest-environment-jsdom` defaults to `['browser']`. `jest-environment-node` defaults to `['node', 'node-addons']`.

These options can also be passed in a docblock, similar to `testEnvironment`. Note that it must be parseable by `JSON.parse`. Example:
These options can also be passed in a docblock, similar to `testEnvironment`. The string with options must be parseable by `JSON.parse`:

```js
/**
Expand Down Expand Up @@ -2238,7 +2246,7 @@ Default: `[]`

An array of regexp pattern strings that are matched against all modules before the module loader will automatically return a mock for them. If a module's path matches any of the patterns in this list, it will not be automatically mocked by the module loader.

This is useful for some commonly used 'utility' modules that are almost always used as implementation details almost all the time (like underscore/lodash, etc). It's generally a best practice to keep this list as small as possible and always use explicit `jest.mock()`/`jest.unmock()` calls in individual tests. Explicit per-test setup is far easier for other readers of the test to reason about the environment the test will run in.
This is useful for some commonly used 'utility' modules that are almost always used as implementation details almost all the time (like `underscore`, `lodash`, etc). It's generally a best practice to keep this list as small as possible and always use explicit `jest.mock()`/`jest.unmock()` calls in individual tests. Explicit per-test setup is far easier for other readers of the test to reason about the environment the test will run in.

It is possible to override this setting in individual tests by explicitly calling `jest.mock()` at the top of the test file.

Expand Down
4 changes: 2 additions & 2 deletions website/versioned_docs/version-29.1/Configuration.md
Expand Up @@ -1128,7 +1128,7 @@ export default config;

:::info

If you also have specified [`rootDir`](#rootdir-string) that the resolution of this file will be relative to that root directory.
If you also have specified [`rootDir`](#rootdir-string), the resolution of this file will be relative to that root directory.

:::

Expand Down Expand Up @@ -1871,7 +1871,7 @@ For example, in `jest-environment-jsdom`, you can override options given to [`js

Both `jest-environment-jsdom` and `jest-environment-node` allow specifying `customExportConditions`, which allow you to control which versions of a library are loaded from `exports` in `package.json`. `jest-environment-jsdom` defaults to `['browser']`. `jest-environment-node` defaults to `['node', 'node-addons']`.

These options can also be passed in a docblock, similar to `testEnvironment`. The string with options must be parseable by `JSON.parse`. Example:
These options can also be passed in a docblock, similar to `testEnvironment`. The string with options must be parseable by `JSON.parse`:

```js
/**
Expand Down

0 comments on commit c72962c

Please sign in to comment.