@@ -50,6 +50,7 @@ change the state of the checkbox.
50
50
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
51
51
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
52
52
53
+
53
54
- [ Installation] ( #installation )
54
55
- [ API] ( #api )
55
56
- [ ` click(element) ` ] ( #clickelement )
@@ -158,8 +159,8 @@ import userEvent from '@testing-library/user-event'
158
159
test (' type' , async () => {
159
160
render (< textarea / > )
160
161
161
- await userEvent .type (screen .getByRole (' textbox' ), ' Hello, World!' )
162
- expect (screen .getByRole (' textbox' )).toHaveAttribute ( ' value ' , ' Hello, World !' )
162
+ await userEvent .type (screen .getByRole (' textbox' ), ' Hello,{enter} World!' )
163
+ expect (screen .getByRole (' textbox' )).toHaveValue ( ' Hello,\n World !' )
163
164
})
164
165
```
165
166
@@ -170,6 +171,32 @@ one character at the time. `false` is the default value.
170
171
are typed. By default it's 0. You can use this option if your component has a
171
172
different behavior for fast or slow users.
172
173
174
+ #### Special characters
175
+
176
+ The following special character strings are supported:
177
+
178
+ | Text string | Key | Modifier | Notes |
179
+ | ------------- | --------- | ---------- | ---------------------------------------------------------------------------------- |
180
+ | ` {enter} ` | Enter | N/A | Will insert a newline character (` <textarea /> ` only). |
181
+ | ` {esc} ` | Escape | N/A | |
182
+ | ` {backspace} ` | Backspace | N/A | Will delete the previous character (or the characters within the ` selectedRange ` ). |
183
+ | ` {shift} ` | Shift | ` shiftKey ` | Does ** not** capitalize following characters. |
184
+ | ` {ctrl} ` | Control | ` ctrlKey ` | |
185
+ | ` {alt} ` | Alt | ` altKey ` | |
186
+ | ` {meta} ` | OS | ` metaKey ` | |
187
+
188
+ > ** A note about modifiers:** Modifier keys (` {shift} ` , ` {ctrl} ` , ` {alt} ` ,
189
+ > ` {meta} ` ) will activate their corresponding event modifiers for the duration
190
+ > of type command or until they are closed (via ` {/shift} ` , ` {/ctrl} ` , etc.).
191
+
192
+ <!-- space out these notes -->
193
+
194
+ > We take the same
195
+ > [ stance as Cypress] ( https://docs.cypress.io/api/commands/type.html#Modifiers )
196
+ > in that we do not simulate the behavior that happens with modifier key
197
+ > combinations as different operating systems function differently in this
198
+ > regard.
199
+
173
200
### ` upload(element, file, [{ clickInit, changeInit }]) `
174
201
175
202
Uploads file to an ` <input> ` . For uploading multiple files use ` <input> ` with
@@ -411,6 +438,7 @@ Thanks goes to these people ([emoji key][emojis]):
411
438
412
439
<!-- markdownlint-enable -->
413
440
<!-- prettier-ignore-end -->
441
+
414
442
<!-- ALL-CONTRIBUTORS-LIST:END -->
415
443
416
444
This project follows the [ all-contributors] [ all-contributors ] specification.
0 commit comments