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: docs/guide/browser/interactivity-api.md
+25-2Lines changed: 25 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -29,6 +29,29 @@ Almost every `userEvent` method inherits its provider options. To see all availa
29
29
```
30
30
:::
31
31
32
+
## userEvent.setup
33
+
34
+
-**Type:**`() => UserEvent`
35
+
36
+
Creates a new user event instance. This is useful if you need to keep the state of keyboard to press and release buttons correctly.
37
+
38
+
::: warning
39
+
Unlike `@testing-library/user-event`, the default `userEvent` instance from `@vitest/browser/context` is created once, not every time its methods are called! You can see the difference in how it works in this snippet:
awaitoriginalUserEvent.keyboard('{Shift}') // press shift without releasing
49
+
awaitoriginalUserEvent.keyboard('{/Shift}') // DID NOT release shift because the state is different
50
+
```
51
+
52
+
This behaviour is more useful because we do not emulate the keyboard, we actually press the Shift, so keeping the original behaviour would cause unexpected issues when typing in the field.
0 commit comments