From ced6dc421d3044a9299853c352128d58e78c1e0f Mon Sep 17 00:00:00 2001 From: Ian VanSchooten Date: Thu, 10 Mar 2022 08:43:54 -0500 Subject: [PATCH] [Addon-interactions] Do not rely on `global` --- addons/interactions/src/preset/argsEnhancers.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/addons/interactions/src/preset/argsEnhancers.ts b/addons/interactions/src/preset/argsEnhancers.ts index a6f1b90c78cf..bdc4329f2115 100644 --- a/addons/interactions/src/preset/argsEnhancers.ts +++ b/addons/interactions/src/preset/argsEnhancers.ts @@ -1,11 +1,13 @@ import { addons } from '@storybook/addons'; import type { Args } from '@storybook/addons'; +import { window as globalWindow } from 'global'; import { FORCE_REMOUNT, STORY_RENDER_PHASE_CHANGED } from '@storybook/core-events'; import type { AnyFramework, ArgsEnhancer } from '@storybook/csf'; import { instrument } from '@storybook/instrumenter'; import { ModuleMocker } from 'jest-mock'; -const JestMock = new ModuleMocker(global); +// The global env is `window` in the browser, and vite does not polyfill `global` as webpack does. +const JestMock = new ModuleMocker(globalWindow); const fn = JestMock.fn.bind(JestMock); // Aliasing `fn` to `action` here, so we get a more descriptive label in the UI.