I am using jest to test a component I made in react hooks. The component I made listens for window resize events from within useEffect(). From my test I can't find a way to trigger a window resize event. Here is my current attempt:
describe ('window resize', () => {
beforeAll(() => {
global.innerWidth = 1500;
global.dispatchEvent(new Event('resize'));
})
it('should do something to check window size', () => {
// Do something
});
});
Aucun commentaire:
Enregistrer un commentaire