question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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:closed
  • Created 2 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

0reactions
netcoding87commented, Mar 21, 2022

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found