diff --git a/packages/vitest/src/integrations/env/jsdom-keys.ts b/packages/vitest/src/integrations/env/jsdom-keys.ts index ea77801552d8..c349f95c1c95 100644 --- a/packages/vitest/src/integrations/env/jsdom-keys.ts +++ b/packages/vitest/src/integrations/env/jsdom-keys.ts @@ -162,6 +162,8 @@ const LIVING_KEYS = [ // not specified in docs, but is available 'Image', + 'Audio', + 'Option', ] const OTHER_KEYS = [ diff --git a/packages/vitest/src/integrations/env/utils.ts b/packages/vitest/src/integrations/env/utils.ts index 074cd9bb5adf..c412ebcef09b 100644 --- a/packages/vitest/src/integrations/env/utils.ts +++ b/packages/vitest/src/integrations/env/utils.ts @@ -15,7 +15,7 @@ const skipKeys = [ export function getWindowKeys(global: any, win: any) { const keys = new Set(KEYS.concat(Object.getOwnPropertyNames(win)) .filter((k) => { - if (k.startsWith('_') || skipKeys.includes(k)) + if (skipKeys.includes(k)) return false if (k in global) return allowRewrite.includes(k) diff --git a/test/core/test/dom.test.ts b/test/core/test/dom.test.ts index 1be843461d7a..1756a5065fe4 100644 --- a/test/core/test/dom.test.ts +++ b/test/core/test/dom.test.ts @@ -27,10 +27,14 @@ it('dispatchEvent doesn\'t throw', () => { expect(() => target.dispatchEvent(event)).not.toThrow() }) -it('Image works as expected', () => { +it('Non-public "live" keys work as expected', () => { const img = new Image(100) + const audio = new Audio() + const option = new Option() expect(img.width).toBe(100) + expect(audio).toBeInstanceOf(window.Audio) + expect(option).toBeInstanceOf(window.Option) }) it('defined on self/window are defined on global', () => {