error when using enzyme mount
elmennani89 opened this issue · comments
Sorry for my English,
I tried to test a component that uses Media component using enzyme and jest but I got this error:
<Media targetWindow> does not support `matchMedia`
I use mount from enzyme.
I've just fixed my tests by adding mock for window.matchMedia
API in the setup file of jest tests.
I assume it could be added in the beforeAll
or before
hooks also if needed.
window.matchMedia = () => ({
addListener: () => {},
removeListener: () => {}
});
Thank you a lot @RusinovAnton , the trick works