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
Copy file name to clipboardExpand all lines: website/docs/12.x/cookbook/basics/async-tests.md
+5-5Lines changed: 5 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,7 +5,7 @@
5
5
Typically, you would write synchronous tests, as they are simple and get the work done. However, there are cases when using asynchronous (async) tests might be necessary or beneficial. The two most common cases are:
6
6
7
7
1.**Testing Code with asynchronous operations**: When your code relies on asynchronous operations, such as network calls or database queries, async tests are essential. Even though you should mock these network calls, the mock should act similarly to the actual behavior and hence by async.
8
-
2.**UserEvent API:** Using the [User Event API](docs/api/events/user-event) in your tests creates more realistic event handling. These interactions introduce delays (even though these are typically event-loop ticks with 0 ms delays), requiring async tests to handle the timing correctly.
8
+
2.**UserEvent API:** Using the [User Event API](/docs/api/events/user-event) in your tests creates more realistic event handling. These interactions introduce delays (even though these are typically event-loop ticks with 0 ms delays), requiring async tests to handle the timing correctly.
9
9
10
10
Using async tests when needed ensures your tests are reliable and simulate real-world conditions accurately.
11
11
@@ -45,9 +45,9 @@ There are several asynchronous utilities you might use in your tests.
45
45
46
46
### `findBy*` queries
47
47
48
-
The most common are the [`findBy*` queries](docs/api/queries#find-by). These are useful when waiting for a matching element to appear. They can be understood as a [`getBy*` queries](docs/api/queries#get-by) used in conjunction with a [`waitFor` function](docs/api/misc/async#waitfor).
48
+
The most common are the [`findBy*` queries](/docs/api/queries#find-by). These are useful when waiting for a matching element to appear. They can be understood as a [`getBy*` queries](/docs/api/queries#get-by) used in conjunction with a [`waitFor` function](/docs/api/misc/async#waitfor).
49
49
50
-
They accept the same predicates as `getBy*` queries like `findByRole`, `findByTest`, etc. They also have a multiple elements variant called [`findAllBy*`](docs/api/queries#find-all-by).
50
+
They accept the same predicates as `getBy*` queries like `findByRole`, `findByTest`, etc. They also have a multiple elements variant called [`findAllBy*`](/docs/api/queries#find-all-by).
51
51
52
52
```typescript
53
53
function findByRole: (
@@ -71,7 +71,7 @@ Each query has a default `timeout` value of 1000 ms and a default `interval` of
Alternatively, a default global `timeout` value can be set using the [`configure` function](docs/api/misc/config#configure):
74
+
Alternatively, a default global `timeout` value can be set using the [`configure` function](/docs/api/misc/config#configure):
75
75
76
76
```typescript
77
77
configure({ asyncUtilTimeout: timeout });
@@ -103,7 +103,7 @@ If you want to use it with `getBy*` queries, use the `findBy*` queries instead,
103
103
104
104
### `waitForElementToBeRemoved` function
105
105
106
-
A specialized function, [`waitForElementToBeRemoved`](docs/api/misc/async#waitforelementtoberemoved), is used to verify that a matching element was present but has since been removed.
106
+
A specialized function, [`waitForElementToBeRemoved`](/docs/api/misc/async#waitforelementtoberemoved), is used to verify that a matching element was present but has since been removed.
-[Jest matchers](docs/api/jest-matchers) - validate assumptions about your UI
15
-
-[User Event](docs/api/events/user-event) - simulate common user interactions like [`press`](docs/api/events/user-event#press) or [`type`](docs/api/events/user-event#type) in a realistic way
16
-
-[Fire Event](docs/api/events/fire-event) - simulate any component event in a simplified way purposes
9
+
-[`render` function](/docs/api/render) - render your UI components for testing purposes
-[Jest matchers](/docs/api/jest-matchers) - validate assumptions about your UI
15
+
-[User Event](/docs/api/events/user-event) - simulate common user interactions like [`press`](/docs/api/events/user-event#press) or [`type`](/docs/api/events/user-event#type) in a realistic way
16
+
-[Fire Event](/docs/api/events/fire-event) - simulate any component event in a simplified way purposes
17
17
- Misc APIs:
18
-
-[`renderHook` function](docs/api/misc/render-hook) - render hooks for testing
It is recommended to use the User Event [`press()`](docs/api/events/user-event#press) helper instead as it offers more realistic simulation of press interaction, including pressable support.
65
+
It is recommended to use the User Event [`press()`](/docs/api/events/user-event#press) helper instead as it offers more realistic simulation of press interaction, including pressable support.
66
66
:::
67
67
68
68
Invokes `press` event handler on the element or parent element in the tree.
It is recommended to use the User Event [`type()`](docs/api/events/user-event#type) helper instead as it offers more realistic simulation of text change interaction, including key-by-key typing, element focus, and other editing events.
101
+
It is recommended to use the User Event [`type()`](/docs/api/events/user-event#type) helper instead as it offers more realistic simulation of text change interaction, including key-by-key typing, element focus, and other editing events.
102
102
:::
103
103
104
104
Invokes `changeText` event handler on the element or parent element in the tree.
Prefer using [`user.scrollTo`](docs/api/events/user-event#scrollto) over `fireEvent.scroll` for `ScrollView`, `FlatList`, and `SectionList` components. User Event provides a more realistic event simulation based on React Native runtime behavior.
156
+
Prefer using [`user.scrollTo`](/docs/api/events/user-event#scrollto) over `fireEvent.scroll` for `ScrollView`, `FlatList`, and `SectionList` components. User Event provides a more realistic event simulation based on React Native runtime behavior.
This allows you to assert whether the given element has the given text content or not. It accepts either `string` or `RegExp` matchers, as well as [text match options](docs/api/queries#text-match-options) of `exact` and `normalizer`.
56
+
This allows you to assert whether the given element has the given text content or not. It accepts either `string` or `RegExp` matchers, as well as [text match options](/docs/api/queries#text-match-options) of `exact` and `normalizer`.
This allows you to assert whether the given `TextInput` element has a specified display value. It accepts either `string` or `RegExp` matchers, as well as [text match options](docs/api/queries#text-match-options) of `exact` and `normalizer`.
90
+
This allows you to assert whether the given `TextInput` element has a specified display value. It accepts either `string` or `RegExp` matchers, as well as [text match options](/docs/api/queries#text-match-options) of `exact` and `normalizer`.
This allows you to assert whether the given element has a specified accessible name. It accepts either `string` or `RegExp` matchers, as well as [text match options](docs/api/queries#text-match-options) of `exact` and `normalizer`.
205
+
This allows you to assert whether the given element has a specified accessible name. It accepts either `string` or `RegExp` matchers, as well as [text match options](/docs/api/queries#text-match-options) of `exact` and `normalizer`.
206
206
207
207
The accessible name will be computed based on `aria-labelledby`, `accessibilityLabelledBy`, `aria-label`, and `accessibilityLabel` props, in the absence of these props, the element text content will be used.
Copy file name to clipboardExpand all lines: website/docs/12.x/docs/api/misc/async.mdx
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
3
3
## `findBy*` queries
4
4
5
-
The `findBy*` queries are used to find elements that are not instantly available but will be added as a result of some asynchronous action. Learn more details [here](docs/api/queries#find-by).
5
+
The `findBy*` queries are used to find elements that are not instantly available but will be added as a result of some asynchronous action. Learn more details [here](/docs/api/queries#find-by).
6
6
7
7
## `waitFor`
8
8
@@ -101,7 +101,7 @@ In order to properly use `waitFor` you need at least React >=16.9.0 (featuring a
101
101
:::
102
102
103
103
:::note
104
-
If you receive warnings related to `act()` function consult our [Understanding Act](docs/advanced/understanding-act.md) function document.
104
+
If you receive warnings related to `act()` function consult our [Understanding Act](/docs/advanced/understanding-act.md) function document.
105
105
:::
106
106
107
107
## `waitForElementToBeRemoved`
@@ -134,5 +134,5 @@ In order to properly use `waitForElementToBeRemoved` you need at least React >=1
134
134
:::
135
135
136
136
:::note
137
-
If you receive warnings related to `act()` function consult our [Understanding 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.
Copy file name to clipboardExpand all lines: website/docs/12.x/docs/api/misc/config.mdx
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -19,7 +19,7 @@ Default timeout, in ms, for async helper functions (`waitFor`, `waitForElementTo
19
19
20
20
### `defaultIncludeHiddenElements` option
21
21
22
-
Default value for [includeHiddenElements](docs/api/queries#includehiddenelements-option) query option for all queries. The default value is set to `false`, so all queries will not match [elements hidden from accessibility](#ishiddenfromaccessibility). This is because the users of the app would not be able to see such elements.
22
+
Default value for [includeHiddenElements](/docs/api/queries#includehiddenelements-option) query option for all queries. The default value is set to `false`, so all queries will not match [elements hidden from accessibility](#ishiddenfromaccessibility). This is because the users of the app would not be able to see such elements.
23
23
24
24
This option is also available as `defaultHidden` alias for compatibility with [React Testing Library](https://testing-library.com/docs/dom-testing-library/api-configuration/#defaulthidden).
`within` (also available as `getQueriesForElement` alias) performs [queries](docs/api/queries) scoped to given element.
11
+
`within` (also available as `getQueriesForElement` alias) performs [queries](/docs/api/queries) scoped to given element.
12
12
13
13
:::note
14
14
Please note that additional `render` specific operations like `update`, `unmount`, `debug`, `toJSON` are _not_ included.
@@ -31,7 +31,7 @@ Use cases for scoped queries include:
31
31
32
32
Useful function to help testing components that use hooks API. By default any `render`, `update`, `fireEvent`, and `waitFor` calls are wrapped by this function, so there is no need to wrap it manually. This method is re-exported from [`react-test-renderer`](https://github.com/facebook/react/blob/main/packages/react-test-renderer/src/ReactTestRenderer.js#L567]).
33
33
34
-
Consult our [Understanding Act function](docs/advanced/understanding-act.md) document for more understanding of its intricacies.
34
+
Consult our [Understanding Act function](/docs/advanced/understanding-act.md) document for more understanding of its intricacies.
0 commit comments