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/docs/api/events/user-event.mdx
+10-6Lines changed: 10 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -53,7 +53,9 @@ await user.press(element);
53
53
54
54
This helper simulates a press on any pressable element, e.g. `Pressable`, `TouchableOpacity`, `Text`, `TextInput`, etc. Unlike `fireEvent.press()`, a more straightforward API that will only call the `onPress` prop, this function simulates the entire press interaction in a more realistic way by reproducing the event sequence emitted by React Native runtime. This helper will trigger additional events like `pressIn` and `pressOut`.
55
55
56
-
## `longPress()`\{#long-press}
56
+
This event will take a minimum of 130 ms to run due to the internal React Native logic. Consider using fake timers to speed up test execution for tests involving `press` and `longPress` interactions.
57
+
58
+
## `longPress()`
57
59
58
60
```ts
59
61
longPress(
@@ -69,7 +71,9 @@ const user = userEvent.setup();
69
71
awaituser.longPress(element);
70
72
```
71
73
72
-
Simulates a long press user interaction. In React Native, the `longPress` event is emitted when the press duration exceeds the long press threshold (by default, 500 ms). In other aspects, this action behaves similarly to regular `press` action, e.g., by emitting `pressIn` and `pressOut` events. The press duration is customizable through the options. This should be useful if you use the `delayLongPress` prop. When using real timers, this will take 500 ms, so it is highly recommended to use that API with fake timers to prevent the test from taking a long time to run.
74
+
Simulates a long press user interaction. In React Native, the `longPress` event is emitted when the press duration exceeds the long press threshold (by default, 500 ms). In other aspects, this action behaves similarly to regular `press` action, e.g., by emitting `pressIn` and `pressOut` events. The press duration is customizable through the options. This should be useful if you use the `delayLongPress` prop.
75
+
76
+
This event will, by default, take 500 ms to run. Due to internal React Native logic, it will take at least 130 ms regardless of the duration option passed. Consider using fake timers to speed up test execution for tests involving `press` and `longPress` interactions.
73
77
74
78
### Options {#longpress-options}
75
79
@@ -107,7 +111,7 @@ This function will add text to the text already present in the text input (as sp
107
111
- `skipPress` - if true, `pressIn` and `pressOut` events will not be triggered.
108
112
- `submitEditing` - if true, `submitEditing` event will be triggered after typing the text.
109
113
110
-
### Sequence of events
114
+
### Sequence of events {#type-sequence}
111
115
112
116
The sequence of events depends on the `multiline` prop and the passed options.
113
117
@@ -156,7 +160,7 @@ This helper simulates the user clearing the content of a `TextInput` element.
156
160
157
161
This function supports only host `TextInput` elements. Passing other element types will result in throwing an error.
158
162
159
-
### Sequence of events
163
+
### Sequence of events {#clear-sequence}
160
164
161
165
Events will not be emitted if the `editable` prop is set to `false`.
162
166
@@ -200,7 +204,7 @@ This helper simulates the user pasting given text to a `TextInput` element.
200
204
201
205
This function supports only host `TextInput` elements. Passing other element types will result in throwing an error.
202
206
203
-
### Sequence of events
207
+
### Sequence of events {#paste-sequence}
204
208
205
209
Events will not be emitted if the `editable` prop is set to `false`.
206
210
@@ -278,7 +282,7 @@ This function will remember where the last scroll ended, so subsequent scroll in
278
282
279
283
To simulate a `FlatList` (and other controls based on `VirtualizedList`) scrolling, you should pass the `contentSize` and `layoutMeasurement` options, which enable the underlying logic to update the currently visible window.
280
284
281
-
### Sequence of events
285
+
### Sequence of events {#scroll-sequence}
282
286
283
287
The sequence of events depends on whether the scroll includes an optional momentum scroll component.
0 commit comments