You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-`[jest-core]`Always use workers in watch mode to avoid crashes ([#14059](https://github.com/facebook/jest/pull/14059)).
11
13
-`[jest-environment-jsdom, jest-environment-node]` Fix assignment of `customExportConditions` via `testEnvironmentOptions` when custom env subclass defines a default value ([#13989](https://github.com/facebook/jest/pull/13989))
12
14
-`[jest-matcher-utils]` Fix copying value of inherited getters ([#14007](https://github.com/facebook/jest/pull/14007))
13
15
-`[jest-mock]` Tweak typings to allow `jest.replaceProperty()` replace methods ([#14008](https://github.com/facebook/jest/pull/14008))
16
+
-`[jest-mock]` Improve user input validation and error messages of `spyOn` and `replaceProperty` methods ([#14087](https://github.com/facebook/jest/pull/14087))
17
+
-`[jest-runtime]` Bind `jest.isolateModulesAsync` to `this` ([#14083](https://github.com/facebook/jest/pull/14083))
14
18
-`[jest-snapshot]` Fix a potential bug when not using prettier and improve performance ([#14036](https://github.com/facebook/jest/pull/14036))
15
19
-`[@jest/transform]` Do not instrument `.json` modules ([#14048](https://github.com/facebook/jest/pull/14048))
16
20
17
21
### Chore & Maintenance
18
22
19
23
-`[docs]` Updated documentation for the `--runTestsByPath` CLI command ([#14004](https://github.com/facebook/jest/pull/14004))
20
24
-`[docs]` Updated documentation regarding the synchronous fallback when asynchronous code transforms are unavailable ([#14056](https://github.com/facebook/jest/pull/14056))
25
+
-`[docs]` Update jest statistics of use and downloads in website Index.
Copy file name to clipboardExpand all lines: docs/JestObjectAPI.md
+17-5
Original file line number
Diff line number
Diff line change
@@ -1039,30 +1039,42 @@ Use the [`--showSeed`](CLI.md#--showseed) flag to print the seed in the test rep
1039
1039
1040
1040
Returns `true` if test environment has been torn down.
1041
1041
1042
-
### `jest.retryTimes(numRetries, options)`
1042
+
### `jest.retryTimes(numRetries, options?)`
1043
1043
1044
-
Runs failed tests n-times until they pass or until the max number of retries is exhausted. `options` are optional. This only works with the default [jest-circus](https://github.com/facebook/jest/tree/main/packages/jest-circus) runner! This must live at the top-level of a test file or in a describe block. Retries _will not_ work if `jest.retryTimes()` is called in a `beforeEach` or a `test` block.
1045
-
1046
-
Example in a test:
1044
+
Runs failed tests n-times until they pass or until the max number of retries is exhausted.
1047
1045
1048
1046
```js
1049
1047
jest.retryTimes(3);
1048
+
1050
1049
test('will fail', () => {
1051
1050
expect(true).toBe(false);
1052
1051
});
1053
1052
```
1054
1053
1055
-
If `logErrorsBeforeRetry` is enabled, Jest will log the error(s) that caused the test to fail to the console, providing visibility on why a retry occurred.
1054
+
If `logErrorsBeforeRetry`option is enabled, error(s) that caused the test to fail will be logged to the console.
1056
1055
1057
1056
```js
1058
1057
jest.retryTimes(3, {logErrorsBeforeRetry:true});
1058
+
1059
1059
test('will fail', () => {
1060
1060
expect(true).toBe(false);
1061
1061
});
1062
1062
```
1063
1063
1064
1064
Returns the `jest` object for chaining.
1065
1065
1066
+
:::caution
1067
+
1068
+
`jest.retryTimes()` must be declared at the top level of a test file or in a `describe` block.
1069
+
1070
+
:::
1071
+
1072
+
:::info
1073
+
1074
+
This function is only available with the default [jest-circus](https://github.com/facebook/jest/tree/main/packages/jest-circus) runner.
1075
+
1076
+
:::
1077
+
1066
1078
### `jest.setTimeout(timeout)`
1067
1079
1068
1080
Set the default timeout interval (in milliseconds) for all tests and before/after hooks in the test file. This only affects the test file from which this function is called. The default timeout interval is 5 seconds if this method is not called.
Copy file name to clipboardExpand all lines: docs/SnapshotTesting.md
+1-1
Original file line number
Diff line number
Diff line change
@@ -106,7 +106,7 @@ Once you're finished, Jest will give you a summary before returning back to watc
106
106
107
107
Inline snapshots behave identically to external snapshots (`.snap` files), except the snapshot values are written automatically back into the source code. This means you can get the benefits of automatically generated snapshots without having to switch to an external file to make sure the correct value was written.
108
108
109
-
**Example:**
109
+
Example:
110
110
111
111
First, you write a test, calling `.toMatchInlineSnapshot()` with no arguments:
Copy file name to clipboardExpand all lines: docs/TutorialReact.md
+2-33
Original file line number
Diff line number
Diff line change
@@ -209,9 +209,9 @@ React 16 triggers these warnings due to how it checks element types, and the moc
209
209
210
210
### DOM Testing
211
211
212
-
If you'd like to assert, and manipulate your rendered components you can use [react-testing-library](https://github.com/kentcdodds/react-testing-library), [Enzyme](https://enzymejs.github.io/enzyme/), or React's [TestUtils](https://reactjs.org/docs/test-utils.html). The following two examples use react-testing-library and Enzyme.
212
+
If you'd like to assert, and manipulate your rendered components you can use [@testing-library/react](https://github.com/testing-library/react-testing-library), [Enzyme](https://enzymejs.github.io/enzyme/), or React's [TestUtils](https://reactjs.org/docs/test-utils.html). The following example use `@testing-library/react`.
213
213
214
-
#### react-testing-library
214
+
#### @testing-library/react
215
215
216
216
```bash npm2yarn
217
217
npm install --save-dev @testing-library/react
@@ -261,37 +261,6 @@ it('CheckboxWithLabel changes the text after click', () => {
261
261
262
262
The code for this example is available at [examples/react-testing-library](https://github.com/facebook/jest/tree/main/examples/react-testing-library).
263
263
264
-
#### Enzyme
265
-
266
-
```bash npm2yarn
267
-
npm install --save-dev enzyme
268
-
```
269
-
270
-
If you are using a React version below 15.5.0, you will also need to install `react-addons-test-utils`.
271
-
272
-
Let's rewrite the test from above using Enzyme instead of react-testing-library. We use Enzyme's [shallow renderer](https://enzymejs.github.io/enzyme/docs/api/shallow.html) in this example.
The code for this example is available at [examples/enzyme](https://github.com/facebook/jest/tree/main/examples/enzyme).
294
-
295
264
### Custom transformers
296
265
297
266
If you need more advanced functionality, you can also build your own transformer. Instead of using `babel-jest`, here is an example of using `@babel/core`:
0 commit comments