Skip to content

Commit 048d17d

Browse files
chore(v13): remove jest preset (#1700)
* refactor: remove jest preset * chore: update docs * chore: remove files entry
1 parent 868a9fc commit 048d17d

File tree

7 files changed

+17
-30
lines changed

7 files changed

+17
-30
lines changed

jest-preset/index.js

-10
This file was deleted.

jest-preset/restore-promise.js

-1
This file was deleted.

jest-preset/save-promise.js

-1
This file was deleted.

jest.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module.exports = {
2-
preset: './jest-preset',
2+
preset: 'react-native',
33
setupFilesAfterEnv: ['./jest-setup.ts'],
44
testPathIgnorePatterns: ['build/', 'examples/', 'experiments-app/', 'timer-utils'],
55
testTimeout: 60000,

package.json

-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
},
4040
"files": [
4141
"build/",
42-
"jest-preset/",
4342
"matchers.js",
4443
"matchers.d.ts",
4544
"pure.js",

website/docs/12.x/docs/api/misc/async.mdx

+15-1
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,12 @@ Avoiding side effects in `expectation` callback can be partially enforced with t
5353

5454
It is also recommended to have a [single assertion per each `waitFor`](https://kentcdodds.com/blog/common-mistakes-with-react-testing-library#having-multiple-assertions-in-a-single-waitfor-callback) for more consistency and faster failing tests. If you want to make several assertions, then they should be in seperate `waitFor` calls. In many cases you won't actually need to wrap the second assertion in `waitFor` since the first one will do the waiting required for asynchronous change to happen.
5555

56+
### Using a React Native version < 0.71 with Jest fake timers
57+
58+
:::caution
59+
When using a version of React Native < 0.71 and modern fake timers (the default for `Jest` >= 27), `waitFor` won't work (it will always timeout even if `expectation()` doesn't throw) unless you use the custom [@testing-library/react-native preset](https://github.com/callstack/react-native-testing-library#custom-jest-preset).
60+
:::
61+
5662
`waitFor` checks whether Jest fake timers are enabled and adapts its behavior in such case. The following snippet is a simplified version of how it behaves when fake timers are enabled:
5763

5864
```tsx
@@ -90,6 +96,10 @@ await waitFor(() => {
9096
}, 10000);
9197
```
9298

99+
:::info
100+
In order to properly use `waitFor` you need at least React >=16.9.0 (featuring async `act`) or React Native >=0.61 (which comes with React >=16.9.0).
101+
:::
102+
93103
:::note
94104
If you receive warnings related to `act()` function consult our [Undestanding Act](docs/advanced/understanding-act.md) function document.
95105
:::
@@ -119,6 +129,10 @@ This method expects that the element is initially present in the render tree and
119129

120130
You can use any of `getBy`, `getAllBy`, `queryBy` and `queryAllBy` queries for `expectation` parameter.
121131

132+
:::info
133+
In order to properly use `waitForElementToBeRemoved` you need at least React >=16.9.0 (featuring async `act`) or React Native >=0.61 (which comes with React >=16.9.0).
134+
:::
135+
122136
:::note
123-
If you receive warnings related to `act()` function consult our [Undestanding Act](docs/advanced/understanding-act.md) function document.
137+
If you receive warnings related to `act()` function consult our [Understanding Act](docs/advanced/understanding-act.md) function document.
124138
:::

website/docs/13.x-alpha/docs/api/misc/async.mdx

+1-15
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,6 @@ Avoiding side effects in `expectation` callback can be partially enforced with t
5353

5454
It is also recommended to have a [single assertion per each `waitFor`](https://kentcdodds.com/blog/common-mistakes-with-react-testing-library#having-multiple-assertions-in-a-single-waitfor-callback) for more consistency and faster failing tests. If you want to make several assertions, then they should be in seperate `waitFor` calls. In many cases you won't actually need to wrap the second assertion in `waitFor` since the first one will do the waiting required for asynchronous change to happen.
5555

56-
### Using a React Native version < 0.71 with Jest fake timers
57-
58-
:::caution
59-
When using a version of React Native < 0.71 and modern fake timers (the default for `Jest` >= 27), `waitFor` won't work (it will always timeout even if `expectation()` doesn't throw) unless you use the custom [@testing-library/react-native preset](https://github.com/callstack/react-native-testing-library#custom-jest-preset).
60-
:::
61-
6256
`waitFor` checks whether Jest fake timers are enabled and adapts its behavior in such case. The following snippet is a simplified version of how it behaves when fake timers are enabled:
6357

6458
```tsx
@@ -96,10 +90,6 @@ await waitFor(() => {
9690
}, 10000);
9791
```
9892

99-
:::info
100-
In order to properly use `waitFor` you need at least React >=16.9.0 (featuring async `act`) or React Native >=0.61 (which comes with React >=16.9.0).
101-
:::
102-
10393
:::note
10494
If you receive warnings related to `act()` function consult our [Undestanding Act](docs/advanced/understanding-act.md) function document.
10595
:::
@@ -129,10 +119,6 @@ This method expects that the element is initially present in the render tree and
129119

130120
You can use any of `getBy`, `getAllBy`, `queryBy` and `queryAllBy` queries for `expectation` parameter.
131121

132-
:::info
133-
In order to properly use `waitForElementToBeRemoved` you need at least React >=16.9.0 (featuring async `act`) or React Native >=0.61 (which comes with React >=16.9.0).
134-
:::
135-
136122
:::note
137-
If you receive warnings related to `act()` function consult our [Undestanding Act](docs/advanced/understanding-act.md) function document.
123+
If you receive warnings related to `act()` function consult our [Understanding Act](docs/advanced/understanding-act.md) function document.
138124
:::

0 commit comments

Comments
 (0)