You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Note that accordingly to the WHATWG forms spec selectionStart, selectionEnd properties and setSelectionRange method apply only to inputs of types text, search, URL, tel and password. Chrome, starting from version 33, throws an exception while accessing those properties and method on the rest of input types. For example, on input of type number: "Failed to read the 'selectionStart' property from 'HTMLInputElement': The input element's type ('number') does not support selection".
This implies that userEvent.clear() is not actually supported for email and number input types, amongst others.
To make matters worse, jsdom (tested on 16.2.2) throws a cryptic exception (InvalidStateError: The object is in an invalid state.) when you try to use .clear() on an unsupported input element, and jest does not print out a call stack, making the problem a bit more painful to find.
The text was updated successfully, but these errors were encountered:
userEvent.clear()
usessetSelectionRange
to clear the input, butsetSelectionRange
is only supported by a subset of input elementsPer https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/setSelectionRange
This implies that
userEvent.clear()
is not actually supported foremail
andnumber
input types, amongst others.To make matters worse,
jsdom
(tested on 16.2.2) throws a cryptic exception (InvalidStateError: The object is in an invalid state.
) when you try to use.clear()
on an unsupported input element, andjest
does not print out a call stack, making the problem a bit more painful to find.The text was updated successfully, but these errors were encountered: