Skip to content

Proper use of async UserEvent methods #910

Answered by ph-fritsche
brandon-lile asked this question in Q&A
Discussion options

You must be logged in to vote

If you get const user = userEvent.setup() at the beginning of the test and then await user.anyApi() for simulating user interaction, you probably won't need to bother what happens under the hood in user-event, the DOM implementation and the JS framework of your choice. I recommend @typescript-eslint/no-floating-promises.

The real user interaction happens concurrently to any code running. The browser implements a UI on top of the DOM and this DOM is programmatically available to JS code which itself runs in the Event Loop. The concurrent real user interactions causes the browser to dispatch events as new macrotasks on the Event Loop.
When a JS test runner like Jest executes JS tests which …

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@brandon-lile
Comment options

@ph-fritsche
Comment options

@brandon-lile
Comment options

Answer selected by brandon-lile
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants