Skip to content

13.0.13 no longer triggering onChange event handler when calling userEvent.type #624

@robin-ambachtsheer

Description

@robin-ambachtsheer
  • @testing-library/user-event version: 13.0.13
  • Testing Framework and version: Jest
  • DOM Environment: jsdom, jest 26.6.3

Relevant code or config

test('input should trigger onchange', () => {
  const onChangeMock = jest.fn();
  const { getByTestId } = render(<input data-testid="input" onChange={onChangeMock} />);
  const input = getByTestId('input');

  userEvent.type(input, 'hello');

  expect(input).toHaveValue('hello');
  expect(onChangeMock).toHaveBeenCalled();
});

Expected output (version 13.0.12)

  ✓ input should trigger onchange (56 ms)

Instead getting (version 13.0.13)

  ✕ input should trigger onchange (54 ms)

  ● input should trigger onchange

    expect(jest.fn()).toHaveBeenCalled()

    Expected number of calls: >= 1
    Received number of calls:    0

      16 |
      17 |   expect(input).toHaveValue('hello');
    > 18 |   expect(onChangeMock).toHaveBeenCalled();
         |                        ^
      19 | });
      20 |
      21 | // test('renders a custom input', () => {

      at Object.<anonymous> (src/hooks/useFormField.test.js:18:24)

I'm assuming this has to do with changes that were made to this file 5c40248?branch=5c40248c0a2bad32ece26319458e88f44eed6e64&diff=split#diff-a95e781d26472f11b0c7fb9827c835cc5ffac421a1867c09be9aaa6212e027c4

It look likes the value is still being set on the element, but the onChange event is not being triggered.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingreleased

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions