From ea715e8fd88cdeaf34bba651d7feb489f947607f Mon Sep 17 00:00:00 2001 From: Sindre Gulseth Date: Wed, 24 Apr 2024 09:59:33 +0200 Subject: [PATCH] fix(cli): mock matchMedia window function (#6472) --- .../src/_internal/cli/util/mockBrowserEnvironment.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/packages/sanity/src/_internal/cli/util/mockBrowserEnvironment.ts b/packages/sanity/src/_internal/cli/util/mockBrowserEnvironment.ts index 40e0c80f64a..c32c5eee643 100644 --- a/packages/sanity/src/_internal/cli/util/mockBrowserEnvironment.ts +++ b/packages/sanity/src/_internal/cli/util/mockBrowserEnvironment.ts @@ -63,6 +63,13 @@ const getFakeGlobals = (basePath: string) => ({ InputEvent: global.window?.InputEvent, customElements: global.window?.customElements, ResizeObserver: global.window?.ResizeObserver || ResizeObserver, + matchMedia: + global.window?.matchMedia || + (() => ({ + matches: false, + media: '', + onchange: null, + })), }) function provideFakeGlobals(basePath: string): () => void {