diff --git a/packages/vitest/package.json b/packages/vitest/package.json index ec1bc6abd11f..62eba7d34888 100644 --- a/packages/vitest/package.json +++ b/packages/vitest/package.json @@ -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", diff --git a/packages/vitest/src/integrations/env/jsdom-keys.ts b/packages/vitest/src/integrations/env/jsdom-keys.ts index 9e731dca0bbc..7fe0e5275a3a 100644 --- a/packages/vitest/src/integrations/env/jsdom-keys.ts +++ b/packages/vitest/src/integrations/env/jsdom-keys.ts @@ -188,9 +188,9 @@ const LIVING_KEYS = [ const OTHER_KEYS = [ 'addEventListener', 'alert', - 'atob', + // 'atob', 'blur', - 'btoa', + // 'btoa', 'cancelAnimationFrame', /* 'clearInterval', */ /* 'clearTimeout', */ diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 2165417fb747..6f378c7f5b71 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1319,7 +1319,7 @@ importers: version: 0.8.1 vite: specifier: ^5.0.0-beta.19 - version: 5.0.0-beta.19(@types/node@18.16.19) + version: 5.0.0-beta.19(@types/node@18.18.9)(less@4.1.3) vite-node: specifier: workspace:* version: link:../vite-node @@ -1388,8 +1388,8 @@ importers: specifier: ^12.10.3 version: 12.10.3 jsdom: - specifier: ^22.1.0 - version: 22.1.0 + specifier: ^23.0.1 + version: 23.0.1 log-update: specifier: ^6.0.0 version: 6.0.0 @@ -13679,6 +13679,14 @@ packages: whatwg-url: 12.0.1 dev: true + /data-urls@5.0.0: + resolution: {integrity: sha512-ZYP5VBHshaDAiVZxjbRVcFJpc+4xGgT0bK3vzy1HLN8jTO975HEbuYzZJcHoQEY5K1a0z8YayJkyVETa08eNTg==} + engines: {node: '>=18'} + dependencies: + whatwg-mimetype: 4.0.0 + whatwg-url: 14.0.0 + dev: true + /date-fns@2.29.2: resolution: {integrity: sha512-0VNbwmWJDS/G3ySwFSJA3ayhbURMTJLtwM2DTxf9CWondCnh6DTNlO9JgRSq6ibf4eD0lfMJNBxUdEAHHix+bA==} engines: {node: '>=0.11'} @@ -17122,6 +17130,13 @@ packages: whatwg-encoding: 2.0.0 dev: true + /html-encoding-sniffer@4.0.0: + resolution: {integrity: sha512-Y22oTqIU4uuPgEemfz7NDJz6OeKf12Lsu+QC+s3BVpda64lTiMYCyGwg5ki4vFxkMwQdeZDl2adZoqUgdFuTgQ==} + engines: {node: '>=18'} + dependencies: + whatwg-encoding: 3.1.1 + dev: true + /html-entities@2.3.3: resolution: {integrity: sha512-DV5Ln36z34NNTDgnz0EWGBLZENelNAtkiFA4kyNOG2tDI6Mz1uSWiq1wAKdyjnJwyDiDO7Fa2SO1CTxPXL8VxA==} dev: true @@ -18979,6 +18994,42 @@ packages: - utf-8-validate dev: true + /jsdom@23.0.1: + resolution: {integrity: sha512-2i27vgvlUsGEBO9+/kJQRbtqtm+191b5zAZrU/UezVmnC2dlDAFLgDYJvAEi94T4kjsRKkezEtLQTgsNEsW2lQ==} + engines: {node: '>=18'} + peerDependencies: + canvas: ^2.11.2 + peerDependenciesMeta: + canvas: + optional: true + dependencies: + cssstyle: 3.0.0 + data-urls: 5.0.0 + decimal.js: 10.4.3 + form-data: 4.0.0 + html-encoding-sniffer: 4.0.0 + http-proxy-agent: 7.0.0 + https-proxy-agent: 7.0.2 + is-potential-custom-element-name: 1.0.1 + nwsapi: 2.2.7 + parse5: 7.1.2 + rrweb-cssom: 0.6.0 + saxes: 6.0.0 + symbol-tree: 3.2.4 + tough-cookie: 4.1.3 + w3c-xmlserializer: 5.0.0 + webidl-conversions: 7.0.0 + whatwg-encoding: 3.1.1 + whatwg-mimetype: 4.0.0 + whatwg-url: 14.0.0 + ws: 8.14.2 + xml-name-validator: 5.0.0 + transitivePeerDependencies: + - bufferutil + - supports-color + - utf-8-validate + dev: true + /jsesc@0.5.0: resolution: {integrity: sha512-uZz5UnB7u4T9LvwmFqXii7pZSouaRPorGs5who1Ip7VO0wxanFvBL7GkM6dTHlgX+jhBApRetaWpnDabOeTcnA==} hasBin: true @@ -21817,6 +21868,11 @@ packages: engines: {node: '>=6'} dev: true + /punycode@2.3.1: + resolution: {integrity: sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==} + engines: {node: '>=6'} + dev: true + /puppeteer-core@20.9.0(typescript@5.2.2): resolution: {integrity: sha512-H9fYZQzMTRrkboEfPmf7m3CLDN6JvbxXA3qTtS+dFt27tR+CsFHzPsT6pzp6lYL6bJbAPaR0HaPO6uSi+F94Pg==} engines: {node: '>=16.3.0'} @@ -24811,6 +24867,13 @@ packages: punycode: 2.3.0 dev: true + /tr46@5.0.0: + resolution: {integrity: sha512-tk2G5R2KRwBd+ZN0zaEXpmzdKyOYksXwywulIX95MBODjSzMIuQnQ3m8JxgbhnL1LeVo7lqQKsYa1O3Htl7K5g==} + engines: {node: '>=18'} + dependencies: + punycode: 2.3.1 + dev: true + /traverse@0.3.9: resolution: {integrity: sha512-iawgk0hLP3SxGKDfnDJf8wTz4p2qImnyihM5Hh/sGvQ3K37dPi/w8sRhdNIxYA1TwFwc5mDhIJq+O0RsvXBKdQ==} dev: true @@ -25769,42 +25832,6 @@ packages: - supports-color dev: true - /vite@5.0.0-beta.19(@types/node@18.16.19): - resolution: {integrity: sha512-Huoj7XUlkhSLHhIOf4FgDrxmHJMKgfvG9ocB4kJmTKSeWfLgHIQ86xYC8+eA/RBxFo9zRQXX81VUgW8l7Wri3Q==} - engines: {node: ^18.0.0 || >=20.0.0} - hasBin: true - peerDependencies: - '@types/node': ^18.0.0 || >=20.0.0 - less: '*' - lightningcss: ^1.21.0 - sass: '*' - stylus: '*' - sugarss: '*' - terser: ^5.4.0 - peerDependenciesMeta: - '@types/node': - optional: true - less: - optional: true - lightningcss: - optional: true - sass: - optional: true - stylus: - optional: true - sugarss: - optional: true - terser: - optional: true - dependencies: - '@types/node': 18.16.19 - esbuild: 0.19.5 - postcss: 8.4.31 - rollup: 4.4.0 - optionalDependencies: - fsevents: 2.3.3 - dev: false - /vite@5.0.0-beta.19(@types/node@18.18.9)(less@4.1.3): resolution: {integrity: sha512-Huoj7XUlkhSLHhIOf4FgDrxmHJMKgfvG9ocB4kJmTKSeWfLgHIQ86xYC8+eA/RBxFo9zRQXX81VUgW8l7Wri3Q==} engines: {node: ^18.0.0 || >=20.0.0} @@ -26111,6 +26138,13 @@ packages: xml-name-validator: 4.0.0 dev: true + /w3c-xmlserializer@5.0.0: + resolution: {integrity: sha512-o8qghlI8NZHU1lLPrpi2+Uq7abh4GGPpYANlalzWxyWteJOCsr/P+oPBA49TOLu5FTZO4d3F9MnWJfiMo4BkmA==} + engines: {node: '>=18'} + dependencies: + xml-name-validator: 5.0.0 + dev: true + /wait-port@1.0.4: resolution: {integrity: sha512-w8Ftna3h6XSFWWc2JC5gZEgp64nz8bnaTp5cvzbJSZ53j+omktWTDdwXxEF0jM8YveviLgFWvNGrSvRHnkyHyw==} engines: {node: '>=10'} @@ -26539,6 +26573,13 @@ packages: iconv-lite: 0.6.3 dev: true + /whatwg-encoding@3.1.1: + resolution: {integrity: sha512-6qN4hJdMwfYBtE3YBTTHhoeuUrDBPZmbQaxWAqSALV/MeEnR5z1xd8UKud2RAkFoPkmB+hli1TZSnyi84xz1vQ==} + engines: {node: '>=18'} + dependencies: + iconv-lite: 0.6.3 + dev: true + /whatwg-mimetype@2.3.0: resolution: {integrity: sha512-M4yMwr6mAnQz76TbJm914+gPpB/nCwvZbJU28cUD6dR004SAxDLOOSUaB1JDRqLtaOV/vi0IC5lEAGFgrjGv/g==} dev: true @@ -26548,6 +26589,11 @@ packages: engines: {node: '>=12'} dev: true + /whatwg-mimetype@4.0.0: + resolution: {integrity: sha512-QaKxh0eNIi2mE9p2vEdzfagOKHCcj1pJ56EEHGQOVxp8r9/iszLUUV7v89x9O1p/T+NlTM5W7jW6+cz4Fq1YVg==} + engines: {node: '>=18'} + dev: true + /whatwg-url@11.0.0: resolution: {integrity: sha512-RKT8HExMpoYx4igMiVMY83lN6UeITKJlBQ+vR/8ZJ8OCdSiN3RwCq+9gH0+Xzj0+5IrM6i4j/6LuvzbZIQgEcQ==} engines: {node: '>=12'} @@ -26564,6 +26610,14 @@ packages: webidl-conversions: 7.0.0 dev: true + /whatwg-url@14.0.0: + resolution: {integrity: sha512-1lfMEm2IEr7RIV+f4lUNPOqfFL+pO+Xw3fJSqmjX9AbXcXcYOkCe1P6+9VBZB6n94af16NfZf+sSk0JCBZC9aw==} + engines: {node: '>=18'} + dependencies: + tr46: 5.0.0 + webidl-conversions: 7.0.0 + dev: true + /whatwg-url@5.0.0: resolution: {integrity: sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==} dependencies: @@ -26950,6 +27004,11 @@ packages: engines: {node: '>=12'} dev: true + /xml-name-validator@5.0.0: + resolution: {integrity: sha512-EvGK8EJ3DhaHfbRlETOWAS5pO9MZITeauHKJyb8wyajUfQUenkIg2MvLDTZ4T/TgIcm3HU0TFBgWWboAZ30UHg==} + engines: {node: '>=18'} + dev: true + /xmlchars@2.2.0: resolution: {integrity: sha512-JZnDKK8B0RCDw84FNdDAIpZK+JuJw+s7Lz8nksI7SIuU3UXJJslUthsi+uWBUYOwPFwW7W7PRLRfUKpxjtjFCw==} dev: true diff --git a/test/core/test/environments/happy-dom.spec.ts b/test/core/test/environments/happy-dom.spec.ts index 6ebf212397e2..f61fcf089a17 100644 --- a/test/core/test/environments/happy-dom.spec.ts +++ b/test/core/test/environments/happy-dom.spec.ts @@ -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=') +}) diff --git a/test/core/test/environments/jsdom.spec.ts b/test/core/test/environments/jsdom.spec.ts index 95d47ec3c168..31c5a466fa0d 100644 --- a/test/core/test/environments/jsdom.spec.ts +++ b/test/core/test/environments/jsdom.spec.ts @@ -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')