Closed
Description
react-testing-library
version: 5.4.4react
version: 16.5.2node
version: 10.0.0npm
(oryarn
) version: yarn 1.9.2
Relevant code or config:
test("input key press correctly", () => { // failed
const doSomething = jest.fn();
const doOtherThing = jest.fn();
const { container } = render(
<App doSomething={doSomething} doOtherThing={doOtherThing} />
);
const input = getByTestId(container, "input");
fireEvent.keyPress(input, { key: "Enter", code: 13 });
expect(doSomething.mock.calls.length).toBe(1);
});
What you did:
run test
What happened:
test failed
Reproduction:
https://codesandbox.io/s/jrv9v845v
Problem description:
When use fireEvent.keyPress, the input keyPress event not fired.
I found the doc about this part of the content, but I don't know what different between the keyPress event and change event.
Suggested solution:
I have no idea.