User-event: userEvent.type puts the first typed character at the end of an input

Created on 28 Oct 2020  路  1Comment  路  Source: testing-library/user-event

  • @testing-library/react: "^10.4.5",
  • @testing-library/user-event: "^12.1.10",

Problem description:

import userEvent from '@testing-library/user-event';
import { render, screen } from '@testing-library/react';

it('textarea input', () => {
    render(<textarea />);

    userEvent.type(screen.getByRole('textbox'), 'Hello, World!');
    expect(screen.getByRole('textbox')).toHaveValue('Hello, World!');
}
    Expected the element to have value:
      Hello, World!
    Received:
      ello, World!H

For some reason, the first input symbol goes to the end of the string.

duplicate jsdom

Most helpful comment

I suspect this is a duplicate of #402 caused by an outdated version of jsdom. You can fix this by using Create React App 4 or jest-environment-jsdom-sixteen. If you're still having issues, please post a reproduction with a failing sandbox or project with a package lock file.

>All comments

I suspect this is a duplicate of #402 caused by an outdated version of jsdom. You can fix this by using Create React App 4 or jest-environment-jsdom-sixteen. If you're still having issues, please post a reproduction with a failing sandbox or project with a package lock file.

Was this page helpful?
0 / 5 - 0 ratings