I am testing my component wit react-testing-library and test works well. I just can't get rid of this warning, fireEvent should by wrapped in act out-of-the-box, but I tried to wrap it again and it did'nt help.
Here is my test case.
it.only("should start file upload if file is added to the field", async () => {
jest.useFakeTimers();
const { getByTestId } = wrapper;
const file = new File(["filefilefile"], "videoFile.mxf");
const fileInput = getByTestId("drop-zone").querySelector(
"input[type='file']"
);
fireEvent.change(fileInput, { target: { files: [file] } });
act(() => {
jest.runAllTimers();
});
await wait(() => {
expect(
initialProps.uploadItemVideoFileConnect.calledWith(file, 123)
).toBe(true);
});
});
Here is the warning
Warning: An update to UploadButtonGridComponent inside a test was not wrapped in act(...).
When testing, code that causes React state updates should be wrapped into act(...):
act(() => {
/* fire events that update state */
});
/* assert on the output */