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
Use Admonitions on website #12495 #12951
Changes from 10 commits
2a380ba
af23bdf
6f36c3a
8ba92e7
a8675b3
ceabf93
c7d2bc5
4530b04
f58214c
617202a
55771df
f6cc67d
abb67b5
100dba1
967e0dc
cd03254
2f76630
d1b55d4
0807a44
d9bb4e6
26aa19d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -180,8 +180,11 @@ Alias: `--collectCoverage`. Indicates that test coverage information should be c | |
|
||
Indicates which provider should be used to instrument code for coverage. Allowed values are `babel` (default) or `v8`. | ||
|
||
:::note | ||
|
||
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. | ||
|
||
::: | ||
### `--debug` | ||
|
||
Print debugging info about your Jest config. | ||
|
@@ -309,7 +312,13 @@ Allows the test suite to pass when no files are found. | |
|
||
### `--projects <path1> ... <pathN>` | ||
|
||
Run tests from one or more projects, found in the specified paths; also takes path globs. This option is the CLI equivalent of the [`projects`](configuration#projects-arraystring--projectconfig) configuration option. Note that if configuration files are found in the specified paths, _all_ projects specified within those configuration files will be run. | ||
Run tests from one or more projects, found in the specified paths; also takes path globs. This option is the CLI equivalent of the [`projects`](configuration#projects-arraystring--projectconfig) configuration option. | ||
|
||
:::note | ||
|
||
Note that if configuration files are found in the specified paths, _all_ projects specified within those configuration files will be run. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we can skip the "Note that" starts to all these sentences There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These have been removed from all .md files that have Note admonitions. |
||
|
||
::: | ||
|
||
### `--reporters` | ||
|
||
|
@@ -385,6 +394,8 @@ A JSON string with options that will be passed to the `testEnvironment`. The rel | |
|
||
Adds a `location` field to test results. Useful if you want to report the location of a test in a reporter. | ||
|
||
:::note | ||
|
||
Note that `column` is 0-indexed while `line` is not. | ||
|
||
```json | ||
|
@@ -394,6 +405,7 @@ Note that `column` is 0-indexed while `line` is not. | |
} | ||
``` | ||
|
||
::: | ||
### `--testMatch glob1 ... globN` | ||
|
||
The glob patterns Jest uses to detect test files. Please refer to the [`testMatch` configuration](Configuration.md#testmatch-arraystring) for details. | ||
|
@@ -454,8 +466,14 @@ Watch files for changes and rerun tests related to changed files. If you want to | |
|
||
Watch files for changes and rerun all tests when something changes. If you want to re-run only the tests that depend on the changed files, use the `--watch` option. | ||
|
||
Use `--watchAll=false` to explicitly disable the watch mode. Note that in most CI environments, this is automatically handled for you. | ||
Use `--watchAll=false` to explicitly disable the watch mode. | ||
|
||
:::note | ||
paulreece marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
Note that in most CI environments, this is automatically handled for you. | ||
|
||
::: | ||
|
||
### `--watchman` | ||
|
||
Whether to use [`watchman`](https://facebook.github.io/watchman/) for file crawling. Defaults to `true`. Disable using `--no-watchman`. | ||
Whether to use [`watchman`](https://facebook.github.io/watchman/) for file crawling. Defaults to `true`. Disable using `--no-watchman`. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,13 @@ title: ECMAScript Modules | |
|
||
:::caution | ||
|
||
Note that due to its experimental nature there are many bugs and missing features in Jest's implementation, both known and unknown. You should check out the [tracking issue](https://github.com/facebook/jest/issues/9430) and the [label](https://github.com/facebook/jest/labels/ES%20Modules) on the issue tracker for the latest status. | ||
|
||
::: | ||
|
||
:::note | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is already a |
||
|
||
Also note that the APIs Jest uses to implement ESM support is still [considered experimental by Node](https://nodejs.org/api/vm.html#vm_class_vm_module) (as of version `14.13.1`). | ||
Jest ships with **experimental** support for ECMAScript Modules (ESM). | ||
|
||
The implementation may have bugs and lack features. For the latest status check out the [issue](https://github.com/facebook/jest/issues/9430) and the [label](https://github.com/facebook/jest/labels/ES%20Modules) on the issue tracker. | ||
|
@@ -25,6 +32,7 @@ With the warnings out of the way, this is how you activate ESM support in your t | |
1. Beyond that, we attempt to follow `node`'s logic for activating "ESM mode" (such as looking at `type` in `package.json` or `.mjs` files), see [their docs](https://nodejs.org/api/esm.html#esm_enabling) for details. | ||
1. If you want to treat other file extensions (such as `.jsx` or `.ts`) as ESM, please use the [`extensionsToTreatAsEsm` option](Configuration.md#extensionstotreatasesm-arraystring). | ||
|
||
::: | ||
## Differences between ESM and CommonJS | ||
|
||
Most of the differences are explained in [Node's documentation](https://nodejs.org/api/esm.html#esm_differences_between_es_modules_and_commonjs), but in addition to the things mentioned there, Jest injects a special variable into all executed files - the [`jest` object](JestObjectAPI.md). To access this object in ESM, you need to import it from the `@jest/globals` module or use `import.meta`. | ||
|
@@ -41,6 +49,12 @@ import.meta.jest.useFakeTimers(); | |
|
||
// jest === import.meta.jest => true | ||
``` | ||
:::note | ||
|
||
|
||
Please note that we currently don't support `jest.mock` in a clean way in ESM, but that is something we intend to add proper support for in the future. Follow [this issue](https://github.com/facebook/jest/issues/10025) for updates. | ||
|
||
::: | ||
|
||
## Module mocking in ESM | ||
|
||
|
@@ -98,3 +112,4 @@ const exported = await import('./main.cjs'); | |
|
||
// etc. | ||
``` | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this can be already removed in the latest version of the docs and stay only in older ones.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed it.