Open ericnicolaas opened 2 years ago
This doesn't work with userEvent.type
either with userEvent 13.5.0
const input = screen.getByRole('spinbutton');
await userEvent.type(input, '{arrowdown}');
expect(onChange).toBeCalledWith('6');
I tried something similar to above, and this is still not working with userEvent 14.5.2
Reproduction example
https://codesandbox.io/s/eloquent-tristan-ixhpuv?file=/src/number.test.js
Prerequisites
Number
component with anonChange
handler that calls back to the container.Number
component is rendered with anonChange
func created withjest.fn()
. UseuserEvent
to click into the field and then simulate a down-arrow keyboard press.For example:
Expected behavior
Expected behaviour is for the test to pass. Pressing the down arrow in a browser would cause the number value to reduce by 1 (assuming
step=1
).Actual behavior
Upon running the tests, the test fails with the following result:
User-event version
14.4.3
Environment
Testing Library framework: @testing-library/react@13.4.0 JS framework:
react@18.2.0
Test environment:jest@27.5.1
DOM implementation:jsdom@16.7.0
Additional context
No response