Skip to content

Commit

Permalink
fix(jsdom): don't go into an infinite recusion when calling atob
Browse files Browse the repository at this point in the history
  • Loading branch information
sheremet-va committed Dec 4, 2023
1 parent 39c952a commit da7949d
Show file tree
Hide file tree
Showing 5 changed files with 111 additions and 42 deletions.
2 changes: 1 addition & 1 deletion packages/vitest/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@
"flatted": "^3.2.9",
"get-tsconfig": "^4.7.2",
"happy-dom": "^12.10.3",
"jsdom": "^22.1.0",
"jsdom": "^23.0.1",
"log-update": "^6.0.0",
"micromatch": "^4.0.5",
"p-limit": "^5.0.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/vitest/src/integrations/env/jsdom-keys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,9 @@ const LIVING_KEYS = [
const OTHER_KEYS = [
'addEventListener',
'alert',
'atob',
// 'atob',
'blur',
'btoa',
// 'btoa',
'cancelAnimationFrame',
/* 'clearInterval', */
/* 'clearTimeout', */
Expand Down
137 changes: 98 additions & 39 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions test/core/test/environments/happy-dom.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,8 @@ test('global CSS is injected correctly', () => {
expect(CSS.escape).toBeDefined()
expect(CSS.supports).toBeDefined()
})

test('atob and btoa are available', () => {
expect(atob('aGVsbG8gd29ybGQ=')).toBe('hello world')
expect(btoa('hello world')).toBe('aGVsbG8gd29ybGQ=')
})
5 changes: 5 additions & 0 deletions test/core/test/environments/jsdom.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ test.runIf(nodeMajor >= 18)('fetch, Request, Response, and BroadcastChannel are
expect(BroadcastChannel).toBeDefined()
})

test('atob and btoa are available', () => {
expect(atob('aGVsbG8gd29ybGQ=')).toBe('hello world')
expect(btoa('hello world')).toBe('aGVsbG8gd29ybGQ=')
})

test('toContain correctly handles DOM nodes', () => {
const wrapper = document.createElement('div')
const child = document.createElement('div')
Expand Down

0 comments on commit da7949d

Please sign in to comment.