Skip to content

Commit e13df95

Browse files
committed
feat(type): make delay default to 0
This means that by default you do not need to await it
1 parent 136c8e4 commit e13df95

File tree

4 files changed

+113
-112
lines changed

4 files changed

+113
-112
lines changed

README.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ change the state of the checkbox.
5454
- [API](#api)
5555
- [`click(element, eventInit, options)`](#clickelement-eventinit-options)
5656
- [`dblClick(element, eventInit, options)`](#dblclickelement-eventinit-options)
57-
- [`async type(element, text, [options])`](#async-typeelement-text-options)
57+
- [`type(element, text, [options])`](#typeelement-text-options)
5858
- [`upload(element, file, [{ clickInit, changeInit }])`](#uploadelement-file--clickinit-changeinit-)
5959
- [`clear(element)`](#clearelement)
6060
- [`selectOptions(element, values)`](#selectoptionselement-values)
@@ -151,7 +151,7 @@ test('double click', () => {
151151
})
152152
```
153153

154-
### `async type(element, text, [options])`
154+
### `type(element, text, [options])`
155155

156156
Writes `text` inside an `<input>` or a `<textarea>`.
157157

@@ -160,17 +160,18 @@ import React from 'react'
160160
import {render, screen} from '@testing-library/react'
161161
import userEvent from '@testing-library/user-event'
162162

163-
test('type', async () => {
163+
test('type', () => {
164164
render(<textarea />)
165165

166-
await userEvent.type(screen.getByRole('textbox'), 'Hello,{enter}World!')
166+
userEvent.type(screen.getByRole('textbox'), 'Hello,{enter}World!')
167167
expect(screen.getByRole('textbox')).toHaveValue('Hello,\nWorld!')
168168
})
169169
```
170170

171171
`options.delay` is the number of milliseconds that pass between two characters
172172
are typed. By default it's 0. You can use this option if your component has a
173-
different behavior for fast or slow users.
173+
different behavior for fast or slow users. If you do this, you need to make sure
174+
to `await`!
174175

175176
`type` will click the element before typing. To disable this, set the
176177
`skipClick` option to `true`.
@@ -433,7 +434,7 @@ test('hover', () => {
433434

434435
Unhovers out of `element`.
435436

436-
> See [above](#async-hoverelement) for an example
437+
> See [above](#hoverelement) for an example
437438
438439
### `paste(element, text, eventInit, options)`
439440

0 commit comments

Comments
 (0)