Closed
Description
react-testing-library
version: 4.0.1react
version: 16.4.1node
version: 8.9.4npm
(oryarn
) version: (yarn 1.7.0)
Relevant code or config:
const { container, debug } = render(<input onKeyDown={console.log} />);
fireEvent(
container.getElementsByTagName('input')[0],
new KeyboardEvent('keyDown', { key: 'Enter', keyCode: 13, which: 13 })
);
What you did:
I am trying to simulate keyboard events to validate my input component. To do that I tried to use fireEvent
function with keydown
and keyDown
types but neither worked.
What happened:
Event handlers are not getting called
Reproduction:
https://codesandbox.io/s/n32nmp18rl
Problem description:
I can't simulate any input via keyboard
Suggested solution:
When i tried to simulate events using reacts ref
and react-dom/test-utils
Simulate
class it seemed to work.
Metadata
Metadata
Assignees
Labels
No labels