I try to simulate onChange with fireEvent.change, but get error _react2.fireEvent.change is not a function.
I checked official docs of react testing library, did everything exactly how it's there https://testing-library.com/docs/example-input-event, even created another test where copied all code from docs, and created exactly the same input in react component. Still the same - _react2.fireEvent.change is not a function.
My input
<input
data-testid='input-file'
value={img}
onChange={upImage}
className="file-upload"
type="file"
/>
my Test
it('img preview', () => {
const form = render(<Form addItem={func} />)
const input = form.getByTestId('input-file')
const file = new File(['dummy content'], 'example.png',
{type: 'image/png'})
fireEvent.change(input, { target: { value: {file} } })
})
also, when I check input in test, in console it's showed like this:
Received: <input class="file-upload" data-testid="input-file" type="file" value="" />
there is simply not onChange
Aucun commentaire:
Enregistrer un commentaire