question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

type causes InvalidStateError with <input type="email">

See original GitHub issue

Occurs 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:

  1. 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')
})
  1. Run test
  2. 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:closed
  • Created 3 years ago
  • Comments:16 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
kentcdoddscommented, Jun 6, 2020

That’s what I was thinking. Want to give it a try?

0reactions
kentcdoddscommented, Jun 8, 2020

🎉 This issue has been resolved in version 11.3.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found