diff --git a/packages/vitest/src/integrations/env/utils.ts b/packages/vitest/src/integrations/env/utils.ts index 821b6846e385..f5025888102a 100644 --- a/packages/vitest/src/integrations/env/utils.ts +++ b/packages/vitest/src/integrations/env/utils.ts @@ -2,6 +2,7 @@ import { KEYS } from './jsdom-keys' const allowRewrite = new Set([ 'Event', + 'EventTarget', ]) export function getWindowKeys(global: any, win: any) { diff --git a/test/core/test/dom.test.ts b/test/core/test/dom.test.ts index 97bfdb3a5d3a..8d23b413f383 100644 --- a/test/core/test/dom.test.ts +++ b/test/core/test/dom.test.ts @@ -12,3 +12,9 @@ it('jsdom', () => { expect(dom.outerHTML).toEqual('<Vitest>') }) + +it('dispatchEvent doesn\'t throw', () => { + const target = new EventTarget() + const event = new Event('click') + expect(() => target.dispatchEvent(event)).not.toThrow() +})