From a880d3f17a454a52948af4d32117a4c1d99f2519 Mon Sep 17 00:00:00 2001 From: Vladimir Date: Sun, 27 Mar 2022 12:11:31 +0300 Subject: [PATCH] fix: event target mismatch with global event (#1036) * fix: event target mismatch with global event * test: dom doesn't throw * chore: cleanup --- packages/vitest/src/integrations/env/utils.ts | 1 + test/core/test/dom.test.ts | 6 ++++++ 2 files changed, 7 insertions(+) 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() +})