diff --git a/config/jest.config.js b/config/jest.config.js index a4085df2..dc42a1cd 100644 --- a/config/jest.config.js +++ b/config/jest.config.js @@ -12,8 +12,7 @@ module.exports = { "givens/setup.js", "jest-extended/all", ], - setupFiles: ["/config/jest.polyfills.js"], - testEnvironment: "jsdom", + testEnvironment: "jest-fixed-jsdom", testEnvironmentOptions: { customExportConditions: [""], }, diff --git a/config/jest.polyfills.js b/config/jest.polyfills.js deleted file mode 100644 index c522363b..00000000 --- a/config/jest.polyfills.js +++ /dev/null @@ -1,14 +0,0 @@ -const { TextEncoder, TextDecoder } = require("node:util"); - -Reflect.set(globalThis, "TextEncoder", TextEncoder); -Reflect.set(globalThis, "TextDecoder", TextDecoder); - -const { Blob } = require("node:buffer"); -const { fetch, Request, Response, Headers, FormData } = require("undici"); - -Reflect.set(globalThis, "fetch", fetch); -Reflect.set(globalThis, "Blob", Blob); -Reflect.set(globalThis, "Request", Request); -Reflect.set(globalThis, "Response", Response); -Reflect.set(globalThis, "Headers", Headers); -Reflect.set(globalThis, "FormData", FormData); diff --git a/package.json b/package.json index 23341a79..cdf93c3a 100644 --- a/package.json +++ b/package.json @@ -62,8 +62,8 @@ "graphql": "^16.9.0", "jest": "^29.7.0", "jest-axe": "^9.0.0", - "jest-environment-jsdom": "^29.7.0", "jest-extended": "^4.0.2", + "jest-fixed-jsdom": "^0.0.4", "jsonfile": "^6.1.0", "lodash": "^4.17.21", "msw": "^2.4.9", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index d41129f0..1c5d6753 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -93,12 +93,12 @@ importers: jest-axe: specifier: ^9.0.0 version: 9.0.0 - jest-environment-jsdom: - specifier: ^29.7.0 - version: 29.7.0 jest-extended: specifier: ^4.0.2 version: 4.0.2(jest@29.7.0(@types/node@22.7.4)) + jest-fixed-jsdom: + specifier: ^0.0.4 + version: 0.0.4(jest-environment-jsdom@29.7.0) jsonfile: specifier: ^6.1.0 version: 6.1.0 @@ -2293,6 +2293,12 @@ packages: jest: optional: true + jest-fixed-jsdom@0.0.4: + resolution: {integrity: sha512-P9BVuU55UMoOSqNRTLKajmfFNNP/4W4P+fJYGpgmSkTJbyMzNwjNVBMDoUmFZkvWo4oi1/NXTyF0+hTO1yShBA==} + engines: {node: '>=18.0.0'} + peerDependencies: + jest-environment-jsdom: '>=28.0.0' + jest-get-type@29.6.3: resolution: {integrity: sha512-zrteXnqYxfQh7l5FHyL38jL39di8H8rHoecLH3JNxH3BwOrBsNeabdap5e0I23lD4HHI8W5VFBZqG4Eaq5LNcw==} engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} @@ -5979,6 +5985,10 @@ snapshots: optionalDependencies: jest: 29.7.0(@types/node@22.7.4) + jest-fixed-jsdom@0.0.4(jest-environment-jsdom@29.7.0): + dependencies: + jest-environment-jsdom: 29.7.0 + jest-get-type@29.6.3: {} jest-haste-map@29.7.0: