Skip to content

Commit

Permalink
fix: parent is defined on global, closes #1489
Browse files Browse the repository at this point in the history
  • Loading branch information
sheremet-va committed Jun 14, 2022
1 parent 1c66401 commit 58818f2
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/vitest/src/integrations/env/utils.ts
Expand Up @@ -71,6 +71,7 @@ export function populateGlobal(global: any, win: any, options: PopulateOptions =
global.window = global
global.self = global
global.top = global
global.parent = global

if (global.global)
global.global = global
Expand Down
3 changes: 3 additions & 0 deletions test/core/test/dom.test.ts
Expand Up @@ -13,6 +13,9 @@ declare global {

it('jsdom', () => {
expect(window).toBeDefined()
expect(top).toBeDefined()
expect(parent).toBeDefined()
expect(self).toBeDefined()

const dom = document.createElement('a')
dom.href = 'https://vitest.dev'
Expand Down
2 changes: 2 additions & 0 deletions test/core/test/happy-dom.test.ts
Expand Up @@ -14,6 +14,8 @@ declare global {
it('defined on self/window are defined on global', () => {
expect(self).toBeDefined()
expect(window).toBeDefined()
expect(top).toBeDefined()
expect(parent).toBeDefined()

expect(self.__property_dom).not.toBeDefined()
expect(window.__property_dom).not.toBeDefined()
Expand Down

0 comments on commit 58818f2

Please sign in to comment.