Skip to content

Confusion about entering input into text fields in V14 (user.type vs user.click + user.keyboard) #1041

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

You must be logged in to vote

You can find the docs for .type() in v14 here: https://testing-library.com/docs/user-event/utility#type

I don't think this method will ever by removed from user-event. Any changes to the API would be a major release.

You should use keyboard() if you want to just simulate pressing buttons on the keyboard.
You can use type() if you just want to conveniently insert some text into an input field or textarea.

If you use .type() as a shortcut for "click this input element and start typing", it's fine.
If you use one of the options or use the API on a non-input element, I'd recommend to use .pointer() (or the convenience APIs) and .keyboard() to describe the interaction that you're testing.

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@cjenkscybercom
Comment options

@ph-fritsche
Comment options

Answer selected by cjenkscybercom
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