Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: configuration admonitions #13295

Merged
merged 28 commits into from
Oct 3, 2022
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
20d767a
Configuration admonitions.
paulreece Sep 22, 2022
e1010ff
Update docs/Configuration.md
paulreece Sep 24, 2022
312cd02
Update docs/Configuration.md
paulreece Sep 24, 2022
45ab3f9
Update docs/Configuration.md
paulreece Sep 24, 2022
2041c07
Update docs/Configuration.md
paulreece Sep 24, 2022
b21fec6
Update docs/Configuration.md
paulreece Sep 24, 2022
06161bc
Added revisions and other versions.
paulreece Sep 25, 2022
2fa9319
Merge branch 'configuration_admonitions' of https://github.com/paulre…
paulreece Sep 25, 2022
25c9093
retrigger checks
paulreece Sep 25, 2022
cb8e22c
Added corrections.
paulreece Sep 27, 2022
ab424a1
retrigger checks
paulreece Sep 27, 2022
e6661f3
retrigger checks
paulreece Sep 27, 2022
2ebd06b
retrigger checks
paulreece Sep 27, 2022
556efc0
retrigger checks
paulreece Sep 27, 2022
7872c0c
Update website/versioned_docs/version-28.x/Configuration.md
paulreece Sep 27, 2022
1437b74
Update docs/Configuration.md
paulreece Sep 27, 2022
94690b6
Update website/versioned_docs/version-25.x/Configuration.md
paulreece Sep 27, 2022
a6d34ef
Update website/versioned_docs/version-26.x/Configuration.md
paulreece Sep 27, 2022
ff92876
Update website/versioned_docs/version-27.x/Configuration.md
paulreece Sep 27, 2022
d36cc1e
Update website/versioned_docs/version-28.x/Configuration.md
paulreece Sep 27, 2022
3e205a2
Update website/versioned_docs/version-29.0/Configuration.md
paulreece Sep 27, 2022
c981d50
Update website/versioned_docs/version-29.0/Configuration.md
paulreece Sep 28, 2022
7574318
Added 29.1
paulreece Sep 29, 2022
d072800
retrigger checks
paulreece Sep 30, 2022
13cde19
retrigger checks
paulreece Sep 30, 2022
c65d85e
retrigger checks
paulreece Sep 30, 2022
b6417eb
Merge branch 'main' into configuration_admonitions
SimenB Sep 30, 2022
284aa3a
retrigger checks
paulreece Sep 30, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 20 additions & 8 deletions docs/Configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -277,8 +277,6 @@ These pattern strings match against the full path. Use the `<rootDir>` string to

Indicates which provider should be used to instrument code for coverage. Allowed values are `babel` (default) or `v8`.

Note that using `v8` is considered experimental. This uses V8's builtin code coverage rather than one based on Babel. It is not as well tested, and it has also improved in the last few releases of Node. Using the latest versions of node (v14 at the time of this writing) will yield better results.

### `coverageReporters` \[array&lt;string | \[string, options]&gt;]

Default: `["clover", "json", "lcov", "text"]`
Expand Down Expand Up @@ -764,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 @@ -1126,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 @@ -1754,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 @@ -1865,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 @@ -2226,15 +2232,21 @@ 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.

### `verbose` \[boolean]

Default: `false`
Default: `false` or `true` if there is only one test file to run

Indicates whether each individual test should be reported during the run. All errors will also still be shown on the bottom after execution. Note that if there is only one test file being run it will default to `true`.
Indicates whether each individual test should be reported during the run. All errors will also still be shown on the bottom after execution.

:::note

If there is only one test file being run it will default to `true`.

:::

### `watchPathIgnorePatterns` \[array&lt;string&gt;]

Expand Down
8 changes: 6 additions & 2 deletions website/versioned_docs/version-25.x/Configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -217,12 +217,16 @@ These pattern strings match against the full path. Use the `<rootDir>` string to

Indicates which provider should be used to instrument code for coverage. Allowed values are `babel` (default) or `v8`.

Note that using `v8` is considered experimental. This uses V8's builtin code coverage rather than one based on Babel and comes with a few caveats
:::note

Using `v8` is considered experimental. This uses V8's builtin code coverage rather than one based on Babel and comes with a few caveats

1. Your node version must include `vm.compileFunction`, which was introduced in [node 10.10](https://nodejs.org/dist/latest-v12.x/docs/api/vm.html#vm_vm_compilefunction_code_params_options)
1. Tests needs to run in Node test environment (support for `jsdom` requires [`jest-environment-jsdom-sixteen`](https://www.npmjs.com/package/jest-environment-jsdom-sixteen))
1. V8 has way better data in the later versions, so using the latest versions of node (v13 at the time of this writing) will yield better results

:::note

### `coverageReporters` \[array&lt;string | \[string, options]&gt;]

Default: `["clover", "json", "lcov", "text"]`
Expand Down Expand Up @@ -1374,7 +1378,7 @@ It is possible to override this setting in individual tests by explicitly callin

### `verbose` \[boolean]

Default: `false`
Default: `false` or `true` if there is only one test file to run

Indicates whether each individual test should be reported during the run. All errors will also still be shown on the bottom after execution. Note that if there is only one test file being run it will default to `true`.

Expand Down
8 changes: 6 additions & 2 deletions website/versioned_docs/version-26.x/Configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,11 @@ These pattern strings match against the full path. Use the `<rootDir>` string to

Indicates which provider should be used to instrument code for coverage. Allowed values are `babel` (default) or `v8`.

Note that using `v8` is considered experimental. This uses V8's builtin code coverage rather than one based on Babel. It is not as well tested, and it has also improved in the last few releases of Node. Using the latest versions of node (v14 at the time of this writing) will yield better results.
:::note

Using `v8` is considered experimental. This uses V8's builtin code coverage rather than one based on Babel. It is not as well tested, and it has also improved in the last few releases of Node. Using the latest versions of node (v14 at the time of this writing) will yield better results.

:::

### `coverageReporters` \[array&lt;string | \[string, options]&gt;]

Expand Down Expand Up @@ -1370,7 +1374,7 @@ It is possible to override this setting in individual tests by explicitly callin

### `verbose` \[boolean]

Default: `false`
Default: `false` or `true` if there is only one test file to run

Indicates whether each individual test should be reported during the run. All errors will also still be shown on the bottom after execution. Note that if there is only one test file being run it will default to `true`.

Expand Down
8 changes: 6 additions & 2 deletions website/versioned_docs/version-27.x/Configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,11 @@ These pattern strings match against the full path. Use the `<rootDir>` string to

Indicates which provider should be used to instrument code for coverage. Allowed values are `babel` (default) or `v8`.

Note that using `v8` is considered experimental. This uses V8's builtin code coverage rather than one based on Babel. It is not as well tested, and it has also improved in the last few releases of Node. Using the latest versions of node (v14 at the time of this writing) will yield better results.
:::note

Using `v8` is considered experimental. This uses V8's builtin code coverage rather than one based on Babel. It is not as well tested, and it has also improved in the last few releases of Node. Using the latest versions of node (v14 at the time of this writing) will yield better results.

:::

### `coverageReporters` \[array&lt;string | \[string, options]&gt;]

Expand Down Expand Up @@ -1439,7 +1443,7 @@ It is possible to override this setting in individual tests by explicitly callin

### `verbose` \[boolean]

Default: `false`
Default: `false` or `true` if there is only one test file to run

Indicates whether each individual test should be reported during the run. All errors will also still be shown on the bottom after execution. Note that if there is only one test file being run it will default to `true`.

Expand Down
12 changes: 7 additions & 5 deletions website/versioned_docs/version-28.x/Configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,11 @@ These pattern strings match against the full path. Use the `<rootDir>` string to

Indicates which provider should be used to instrument code for coverage. Allowed values are `babel` (default) or `v8`.

Note that using `v8` is considered experimental. This uses V8's builtin code coverage rather than one based on Babel. It is not as well tested, and it has also improved in the last few releases of Node. Using the latest versions of node (v14 at the time of this writing) will yield better results.
:::note

Using `v8` is considered experimental. This uses V8's builtin code coverage rather than one based on Babel. It is not as well tested, and it has also improved in the last few releases of Node. Using the latest versions of node (v14 at the time of this writing) will yield better results.

:::

### `coverageReporters` \[array&lt;string | \[string, options]&gt;]

Expand Down Expand Up @@ -378,9 +382,7 @@ As a secondary option, an object with the properties `name` and `color` can be p

### `errorOnDeprecated` \[boolean]

Default: `false`

Make calling deprecated APIs throw helpful error messages. Useful for easing the upgrade process.
Default: `false` Make calling deprecated APIs throw helpful error messages. Useful for easing the upgrade process.

### `extensionsToTreatAsEsm` \[array&lt;string&gt;]

Expand Down Expand Up @@ -1685,7 +1687,7 @@ It is possible to override this setting in individual tests by explicitly callin

### `verbose` \[boolean]

Default: `false`
Default: `false` or `true` if there is only one test file to run

Indicates whether each individual test should be reported during the run. All errors will also still be shown on the bottom after execution. Note that if there is only one test file being run it will default to `true`.

Expand Down
6 changes: 2 additions & 4 deletions website/versioned_docs/version-29.0/Configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ import TOCInline from '@theme/TOCInline';

### `automock` \[boolean]

Default: `false`
Default: `false` or `true` if there is only one test file to run

This option tells Jest that all imported modules in your tests should be mocked automatically. All modules used in your tests will have a replacement implementation, keeping the API surface.

Expand Down Expand Up @@ -277,8 +277,6 @@ These pattern strings match against the full path. Use the `<rootDir>` string to

Indicates which provider should be used to instrument code for coverage. Allowed values are `babel` (default) or `v8`.

Note that using `v8` is considered experimental. This uses V8's builtin code coverage rather than one based on Babel. It is not as well tested, and it has also improved in the last few releases of Node. Using the latest versions of node (v14 at the time of this writing) will yield better results.

### `coverageReporters` \[array&lt;string | \[string, options]&gt;]

Default: `["clover", "json", "lcov", "text"]`
Expand Down Expand Up @@ -2232,7 +2230,7 @@ It is possible to override this setting in individual tests by explicitly callin

### `verbose` \[boolean]

Default: `false`
Default: `false` or `true` if there is only one test file to run

Indicates whether each individual test should be reported during the run. All errors will also still be shown on the bottom after execution. Note that if there is only one test file being run it will default to `true`.

Expand Down