diff --git a/src/setupTests.ts b/src/setupTests.ts index 88c8c3b3..85c38370 100644 --- a/src/setupTests.ts +++ b/src/setupTests.ts @@ -2,3 +2,17 @@ import Enzyme from 'enzyme' import Adapter from 'enzyme-adapter-react-16' Enzyme.configure({ adapter: new Adapter() }) + +Object.defineProperty(window, 'matchMedia', { + writable: true, + value: jest.fn().mockImplementation(query => ({ + matches: false, + media: query, + onchange: null, + addListener: jest.fn(), // deprecated + removeListener: jest.fn(), // deprecated + addEventListener: jest.fn(), + removeEventListener: jest.fn(), + dispatchEvent: jest.fn() + })) +}) diff --git a/src/storybook.test.ts b/src/storybook.test.ts index e4e9f666..a21dea41 100644 --- a/src/storybook.test.ts +++ b/src/storybook.test.ts @@ -1,17 +1,3 @@ import initStoryshots from '@storybook/addon-storyshots' -Object.defineProperty(window, 'matchMedia', { - writable: true, - value: jest.fn().mockImplementation(query => ({ - matches: false, - media: query, - onchange: null, - addListener: jest.fn(), // deprecated - removeListener: jest.fn(), // deprecated - addEventListener: jest.fn(), - removeEventListener: jest.fn(), - dispatchEvent: jest.fn() - })) -}) - initStoryshots()