userEvent.type() breaks with a number
See original GitHub issueNot sure if this is a bug, or as intended, so feel free to close 😃
I I just tried to do this:
await userEvent.type(screen.getByPlaceholderText('Price'), item.price);
Where price is a number. That throws the error TypeError: text.slice is not a function
running with toString() fixes that:
await userEvent.type(screen.getByPlaceholderText('Price'), item.price.toString());
Since the browser would coerce to a string if we were setting a value, should this too? Or should I just always coerce it myself?
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:5 (2 by maintainers)
Top Results From Across the Web
user-event v13 - Testing Library
Simulates the keyboard events described by text . This is similar to userEvent.type() but without any clicking or changing the selection range.
Read more >How to use user-event library in conjunction with Jest's fake ...
I'm writing Jest tests for a React component, and using the @testing-library/user-event library to simulate user interaction. This works great, ...
Read more >React Testing Library best practices | Ben Ilegbodu
The type user event writes the specified text into the <textarea> ... {enter} (hitting the ENTER key) instead of a line break (...
Read more >React Testing Techniques - Medium
A refactor can easily break your test. Another example is using certain APIs of a React testing tool called Enzyme, e.g. its instance()...
Read more >Common mistakes with React Testing Library - Kent C. Dodds
You only need to type screen. and let your editor's magic autocomplete take ... toBeDisabled() // error message: // Received element is not ......
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
We’re seeing a situation where
type
with a string on a number input doesn’t work… the browser wants a number to be entered, not a string. Any way to do this?Makes sense! Thanks a lot