From ca616d47669328a37562f7249e789610d98dffd1 Mon Sep 17 00:00:00 2001 From: sam-m-m Date: Mon, 10 Aug 2020 17:14:36 -0700 Subject: [PATCH] Feat #30 - Fix snapshot test bug (matchMedia) --- src/storybook.test.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/storybook.test.ts b/src/storybook.test.ts index 750317cf..e4e9f666 100644 --- a/src/storybook.test.ts +++ b/src/storybook.test.ts @@ -1,2 +1,17 @@ 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()