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
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.
The `fireEventAsync` function is the async version of `fireEvent` designed for working with React 19 and React Suspense. It wraps event handler execution in async `act()`, making it suitable for event handlers that trigger suspense boundaries or other async behavior.
Like `fireEvent`, `fireEventAsync` also provides convenience methods for common events: `fireEventAsync.press`, `fireEventAsync.changeText`, and `fireEventAsync.scroll`.
Async version of `fireEvent.press` designed for React 19 and React Suspense. Use when press event handlers trigger suspense boundaries or other async behavior.
Async version of `fireEvent.changeText` designed for React 19 and React Suspense. Use when changeText event handlers trigger suspense boundaries or other async behavior.
Async version of `fireEvent.scroll` designed for React 19 and React Suspense. Use when scroll event handlers trigger suspense boundaries or other async behavior.
Copy file name to clipboardExpand all lines: website/docs/13.x/docs/api/render.mdx
+40Lines changed: 40 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -64,3 +64,43 @@ React Test Renderer does not enforce this check; hence, by default, React Native
64
64
The `render` function returns the same queries and utilities as the [`screen`](docs/api/screen) object. We recommended using the `screen` object as more developer-friendly way.
65
65
66
66
See [this article](https://kentcdodds.com/blog/common-mistakes-with-react-testing-library#not-using-screen) from Kent C. Dodds for more details.
67
+
68
+
## `renderAsync` function
69
+
70
+
:::info RNTL minimal version
71
+
72
+
This API requires RNTL v13.3.0 or later.
73
+
74
+
:::
75
+
76
+
```jsx
77
+
asyncfunctionrenderAsync(
78
+
component:React.Element<any>,
79
+
options?:RenderAsyncOptions
80
+
): Promise<RenderAsyncResult>
81
+
```
82
+
83
+
The `renderAsync` function is the async version of `render` designed for working with React 19 and React Suspense. It allows components to be properly rendered when they contain suspense boundaries or async behavior that needs to complete before the render result is returned.
84
+
85
+
```jsx
86
+
import { renderAsync, screen } from '@testing-library/react-native';
`renderAsync` accepts the same options as `render`.
97
+
98
+
### Result
99
+
100
+
The `renderAsync` function returns a promise that resolves to the same queries and utilities as the [`screen`](docs/api/screen) object. We recommend using the `screen` object for queries and the async lifecycle methods from the render result when needed.
101
+
102
+
:::note Async lifecycle methods
103
+
104
+
When using `renderAsync`, you have to use correspodning lifecycle methods: `updateAsync`/`rerenderAsync` and `unmountAsync` instead of their sync versions.
Copy file name to clipboardExpand all lines: website/docs/13.x/docs/api/screen.mdx
+51Lines changed: 51 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -41,6 +41,35 @@ function rerender(element: React.Element<unknown>): void;
41
41
42
42
Re-render the in-memory tree with a new root element. This simulates a React update render at the root. If the new element has the same type (and `key`) as the previous element, the tree will be updated; otherwise, it will re-mount a new tree, in both cases triggering the appropriate lifecycle events.
43
43
44
+
### `rerenderAsync`
45
+
46
+
_Also available under `updateAsync` alias_
47
+
48
+
:::info RNTL minimal version
49
+
50
+
This API requires RNTL v13.3.0 or later.
51
+
52
+
:::
53
+
54
+
```ts
55
+
function rerenderAsync(element:React.Element<unknown>):Promise<void>;
56
+
```
57
+
58
+
Async versions of `rerender` designed for working with React 19 and React Suspense. These methods wait for async operations to complete during re-rendering, making them suitable for components that use suspense boundaries or other async behavior.
Unmount the in-memory tree, triggering the appropriate lifecycle events.
51
80
52
81
:::note
82
+
83
+
Usually you should not need to call `unmount` as it is done automatically if your test runner supports `afterEach` hook (like Jest, mocha, Jasmine).
84
+
85
+
:::
86
+
87
+
### `unmountAsync`
88
+
89
+
:::info RNTL minimal version
90
+
91
+
This API requires RNTL v13.3.0 or later.
92
+
93
+
:::
94
+
95
+
```ts
96
+
function unmountAsync():Promise<void>;
97
+
```
98
+
99
+
Async version of `unmount` designed for working with React 19 and React Suspense. This method waits for async cleanup operations to complete during unmounting, making it suitable for components that have async cleanup behavior.
100
+
101
+
:::note
102
+
53
103
Usually you should not need to call `unmount` as it is done automatically if your test runner supports `afterEach` hook (like Jest, mocha, Jasmine).
0 commit comments