0
votes

I am using jest & react-testing-library. In my component on didMount I add an event listener to the window reacting on resize events. Based on resize events, another function is called. In my test, that function is mocked.

Now I have the problem, that I am not able to trigger these resize events. Is there any way to get that done?

   window.resizeTo(500, 500);
   fireEvent.resize(window);
   fireEvent(window, new Event("resize"));

I tried to achieve the triggering of the event listener on different ways, but nothing worked.

Thanks for your help in advance :)