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
the test will type 91 and expect 91 people as outcome
the input value ends up being 9 people 😢🔴
Please check the browsers where the issue is seen
Chrome
Chrome (Android)
Safari (OSX)
Safari (iOS)
Firefox
Firefox (Android)
jest + testing-library
Additional details
After a lot of local debugging; it seems that when userEvent tries to type 1 (from 91); the caret is placed at the end of the input, so the input value is: 9 people1 which gets cleaned up back to 9 people making it fail
The text was updated successfully, but these errors were encountered:
- if (el.value === currentValue && el.selectionStart !== el.selectionEnd) {+ if (el.value === currentValue && el.selectionStart !== caretPos) {
But I would like to understand why the current check is needed before I open a PR proposing my change.
Update:
I actually see my "solution" was proposed here: #736 (comment) but it ended up being different; so yeah, I'd love to know why it is checking against el.selectionEnd instead of caretPos
Describe the issue and the actual behavior
typing a number with 2 digits in a NumericFormat with
suffix
result in the wrong value when done in a jest test.Describe the expected behavior
typing with jest should result in the same behavior as if typing in browser
Provide a CodeSandbox link illustrating the issue
https://codesandbox.io/s/recursing-poitras-rxtjkj?file=/src/index.test.js
Provide steps to reproduce this issue
9
9 people
✅9
✅1
91 people
✅1
✅91
and expect91 people
as outcome9 people
😢🔴Please check the browsers where the issue is seen
jest
+testing-library
Additional details
After a lot of local debugging; it seems that when
userEvent
tries to type1
(from91
); the caret is placed at the end of the input, so the input value is:9 people1
which gets cleaned up back to9 people
making it failThe text was updated successfully, but these errors were encountered: