testing-library / user-event

🐕 Simulate user events
https://testing-library.com/user-event
MIT License
2.19k stars 249 forks source link

user.type does not trigger validations for "minlength" #1221

Closed KonnorRogers closed 5 months ago

KonnorRogers commented 6 months ago

Reproduction example

https://codesandbox.io/p/devbox/pm73nz?file=%2Fsrc%2Findex.test.jsx%3A25%2C1

Prerequisites

  1. Render an <input minlength="10"> element.
  2. Setup user-event
  3. do input.focus(); await user.type("{1}{2}{3}")
  4. Expect input.validity.tooShort to be true, expect input.validationMessage to not be an empty string. Basically, expect it to trigger native constraint validation

Expected behavior

Expect behavior:

When typing 123 into a <input minlength="10"> I expect native constraint validation to be trigger.

https://developer.mozilla.org/en-US/docs/Web/API/ValidityState/tooShort https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/minlength

Actual behavior

Native constraint validation never triggers

User-event version

14.5.2

Environment

No response

Additional context

No response

ph-fritsche commented 5 months ago

Closing this as duplicate of #801 .