@@ -158,8 +158,8 @@ import userEvent from '@testing-library/user-event'
158158test (' type' , async () => {
159159 render (< textarea / > )
160160
161- await userEvent .type (screen .getByRole (' textbox' ), ' Hello, World!' )
162- expect (screen .getByRole (' textbox' )).toHaveAttribute ( ' value ' , ' Hello, World !' )
161+ await userEvent .type (screen .getByRole (' textbox' ), ' Hello{enter} World!' )
162+ expect (screen .getByRole (' textbox' )).toHaveValue ( ' Hello\n World !' )
163163})
164164```
165165
@@ -170,6 +170,25 @@ one character at the time. `false` is the default value.
170170are typed. By default it's 0. You can use this option if your component has a
171171different behavior for fast or slow users.
172172
173+ #### Special characters
174+
175+ The following special character strings are supported:
176+
177+ | Text string | Key | Modifier | Notes |
178+ | ------------- | --------- | ---------- | ------------------------------------------------------ |
179+ | ` {enter} ` | Enter | N/A | Will insert a newline character (` <textarea /> ` only). |
180+ | ` {esc} ` | Escape | N/A | |
181+ | ` {backspace} ` | Backspace | N/A | Will delete the previous character. |
182+ | ` {shift} ` | Shift | ` shiftKey ` | Does ** not** capitalize following characters. |
183+ | ` {ctrl} ` | Control | ` ctrlKey ` | |
184+ | ` {alt} ` | Alt | ` altKey ` | |
185+ | ` {meta} ` | OS | ` metaKey ` | |
186+
187+ > ** A note about modifiers:** Modifier keys (` {shift} ` , ` {ctrl} ` , ` {alt} ` ,
188+ > ` {meta} ` ) will activate their corresponding event modifiers for the duration
189+ > of type command. Keys are released in the same sequence that they were invoked
190+ > at the end of typing.
191+
173192### ` upload(element, file, [{ clickInit, changeInit }]) `
174193
175194Uploads file to an ` <input> ` . For uploading multiple files use ` <input> ` with
@@ -400,6 +419,7 @@ Thanks goes to these people ([emoji key][emojis]):
400419
401420<!-- markdownlint-enable -->
402421<!-- prettier-ignore-end -->
422+
403423<!-- ALL-CONTRIBUTORS-LIST:END -->
404424
405425This project follows the [ all-contributors] [ all-contributors ] specification.
0 commit comments