type causes InvalidStateError with <input type="email">
See original GitHub issueOccurs in master of @testing-library/user-event
version: 11.2.1
Here’s an example failing test, not really up to this library’s standards but I wanted to get as close to the source as possible.
STR:
- Add the following block to src/__tests__/type.js
const create = () => {
const utils = render(<input aria-label="input" type="email"/>)
const input = utils.getByLabelText('input')
return {
input,
...utils,
}
}
it('types text in email input', async () => {
const { input } = create()
await userEvent.type(input, 'testing@gmail.com')
expect(input.value).toBe('testing@gmail.com')
})
- Run test
InvalidStateError
What happened: I wanted to follow up on this comment and reproduce: https://github.com/testing-library/user-event/issues/307#issuecomment-639226751. Sorry @kentcdodds, the type=
was abstracted away and it was pretty silly of me to assume it was text. Seems like I ran into 2 completely different issues now, but hopefully I’m just missing something obvious.
Test fails on InvalidStateError
, adding an onChange
handler with a console.log(event.target.value)
shows that type
only enters in the first char before breaking.
Issue Analytics
- State:
- Created 3 years ago
- Comments:16 (11 by maintainers)
Top Results From Across the Web
Why shouldn't a user/agent be able to select an email ...
We have no ways to get precise display values of type=email and type=number because of IDNA, value sanitization, and localization.
Read more ><input type="email"> - HTML: HyperText Markup Language
When you create an email input with the proper type value, email , you get automatic validation that the entered text is at...
Read more >Exception when setting selectionStart property on email input
InvalidStateError: Failed to set the 'selectionStart' property on 'HTMLInputElement': The input element's type ('email') does not support ...
Read more >4.10.5 The input element - HTML Standard - WhatWG
† If the control has no selectable text, the select() method results in a no-op, with no " InvalidStateError " DOMException . Some...
Read more >HTML 5.2: 4.10. Forms
However, there could be a number of different form controls used for the purpose: a free text field ( <input type=text> ), a...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
That’s what I was thinking. Want to give it a try?
🎉 This issue has been resolved in version 11.3.1 🎉
The release is available on:
npm package (@latest dist-tag)
Your semantic-release bot 📦🚀