userEvent.type writes text correctly. But I'm not sure how it behaves with special characters like 猫 or 馃憤 .
It would be good to have tests covering these cases
First of all thank you for merging my PR.
Yes, I have been thinking about this today. I think the behaviour of entering special character differ per language of keyboard being used. Do we just want to restrict this to the probably most used American keyboard?
Beside of that do we want to enter capital letters correctly too? E.g. Shift + Letter? What about the enter key for a \n?
That's a good point. I think supporting every possible keyboard layout out there is too much work and out of the scope of this project. I would just assume that if a character is typed, it's because it was somewhere on the keyboard. That includes uppercase letters.
Cypress has support for special characters like enter. We could think to do the same https://docs.cypress.io/api/commands/type.html#Arguments
Yes, that's true. I will have a closer look at the Cypress command for type. Maybe we can borrow some ideas. Wondering how Cypress supports uppercase letters at the moment, though
While looking into a react-testing-library issue I discovered this package https://github.com/eventualbuddha/keysim.js . Maybe it's interesting to leverage for the type-behaviour?
The thing is this library is based on fireEvent, I don't know how that would fit with keysim
Yeah, that's a good point. Maybe I borrow some ideas from that library :)
Sorry, I haven't had a need yet to support special characters. I might consider with adding support {backspace} / {ctrl} {meta} etc first. I will have a closer look at how it works in Cypress again.
Hi, is there any progress on this? What have people been doing to simulate enter key presses if userEvent.type(textArea, "Testing!{enter}"); doesn't work?
Yes, I have some of it in a local branch at work
There is no on going work related to support _"press enter"_ action? I will be happy to contribute if there is nothing in place yet, nevertheless, looks odd because it should be a very common usage case. Isn't? What does the people do now?
I have tried with:
fireEvent.keyDown(searchInput, {
charCode: 13,
code: 13,
key: 'Enter',
keyCode: 13,
})
And it doesn't work to trigger the submit of the form I have
UPDATE: there is a submit event fireEvent.submit(searchInput) check all events at https://github.com/testing-library/dom-testing-library/blob/master/src/events.js
:tada: This issue has been resolved in version 11.1.0 :tada:
The release is available on:
npm package (@latest dist-tag)Your semantic-release bot :package::rocket:
Most helpful comment
There is no on going work related to support _"press enter"_ action? I will be happy to contribute if there is nothing in place yet, nevertheless, looks odd because it should be a very common usage case. Isn't? What does the people do now?
I have tried with:
And it doesn't work to trigger the submit of the form I have
UPDATE: there is a submit event
fireEvent.submit(searchInput)check all events at https://github.com/testing-library/dom-testing-library/blob/master/src/events.js