userEvent.type() doesn't work
See original GitHub issue@testing-library/user-event
version: 13.1.5
Code from docs
import React from 'react'
import {render, screen} from '@testing-library/react'
import userEvent from '@testing-library/user-event'
test('type', () => {
render(<textarea />)
userEvent.type(screen.getByRole('textbox'), 'Hello, World!')
expect(screen.getByRole('textbox')).toHaveValue('Hello, World!')
})
What you did: ran this code
What happened: got an error, because it received ‘H’ instead ‘Hello, World!’
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
userEvent.type not updating value of input in test
I am testing this component, which is simply changing its state depending on new input into the input field and setting the value...
Read more >Test fails when using userEvent.type for an input element of ...
I just use debug() to show the DOM state then I find the input value does not update but show 0 . Note,...
Read more >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 >Simulate Typing into Form Fields in Tests with the User Event ...
At the beginning of this lesson we add a missing aria-label property to an <input> element to make it both more accessible and...
Read more >userEvent.type Reverses Value - CodeSandbox
When a value is intercepted during on change and formatted before being set on an input, userEvent.type doesn't appropriately handle it and reverses...
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
@netcoding87 Fixed your event handler: https://codesandbox.io/s/recursing-haze-48u6to?file=/src/MyInput.tsx
Thanks. Just try to think why this small change makes such a difference 🧐 It must be sth with how React is calling the callback passed into the set function of the state and how the values are evaluated.