Closed
Description
DOM Testing Library
version: "@testing-library/dom": "^6.10.1" and "@testing-library/react": "^9.3.2",`node
version: v12.13.1`npm
(oryarn
) version: yarn 1.19.1`
Relevant code or config:
const { container } = render(<ModelsForm />);
const input = (container as HTMLDivElement).querySelector('input');
fireEvent.change(input, { target: { value: 'test' } });
fireEvent.keyPress(input, { key: 'Enter', code: 13 });
What you did:
I am trying to test a small component which contains an input type="text"
If I fireEvent.change(input, { target: { value: 'test' } });
I can expect its value and it is changed to test
as expected
But if I fireEvent.keyPress(input, { key: 'Enter', code: 13 });
, my mocked function is never called
What happened:
fireEvent.keyPress(input, { key: 'Enter', code: 13 });
mocked function is never called. Looks like it ignores the event
Reproduction:
https://codesandbox.io/s/react-testing-library-demo-2l41s
Problem description:
fireEvent keyPress is not working
Metadata
Metadata
Assignees
Labels
No labels