-
Couldn't load subscription status.
- Fork 153
feat(rule): add no-await-sync-events rule #240
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
8017327
ce84207
780ac25
295ba37
47759a6
d3c3897
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,7 +6,9 @@ Ensure that sync events are not awaited unnecessarily. | |
|
|
||
| Functions in the event object provided by Testing Library, including | ||
| fireEvent and userEvent, do NOT return Promise, with an exception of | ||
| `userEvent.type`. Some examples are: | ||
| `userEvent.type`, which delays the promise resolve only if [`delay` | ||
| option](https://github.com/testing-library/user-event#typeelement-text-options) is specified. | ||
| Some examples are: | ||
|
|
||
| - `fireEvent.click` | ||
| - `fireEvent.select` | ||
|
|
@@ -29,6 +31,12 @@ const bar = () => { | |
| await userEvent.tab(); | ||
| // ... | ||
| }; | ||
|
|
||
| const baz = () => { | ||
| // ... | ||
| await userEvent.type(textInput, 'abc'); | ||
| // ... | ||
| }; | ||
| ``` | ||
|
|
||
| Examples of **correct** code for this rule: | ||
|
|
@@ -45,6 +53,12 @@ const bar = () => { | |
| userEvent.tab(); | ||
| // ... | ||
| }; | ||
|
|
||
| const baz = () => { | ||
| // ... | ||
| await userEvent.type(textInput, 'abc', {delay: 1000}); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you add an extra correct example for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. updated |
||
| // ... | ||
| }; | ||
| ``` | ||
|
|
||
| ## Notes | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.