Confusion about entering input into text fields in V14 (user.type vs user.click + user.keyboard) #1041
-
I've just started using this library, using v14 as recommended in the docs since v13.5 is EOL. A lot of what I see online in e.g. StackOverflow uses the userEvent.type(someElement, 'some text') methods, however according to the docs this is a v13 method so I assume it'll be deprecated and that there's a recommended way of doing this in v14. However, I don't see a similar convenience method in v14, or any guideline in the v13 docs on what to do instead of this old method. So, is it supposed to be quite literally something like this? (click on the field, then type on the keyboard)
The confusing part is that I can still use the old method, e.g.
And both do what I expect them to in tests. Can anyone please help clarify this? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
You can find the docs for I don't think this method will ever by removed from
If you use |
Beta Was this translation helpful? Give feedback.
You can find the docs for
.type()
inv14
here: https://testing-library.com/docs/user-event/utility#typeI don't think this method will ever by removed from
user-event
. Any changes to the API would be a major release.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.