diff --git a/integration/form-test.ts b/integration/form-test.ts index 1b829899b9..1d99cee902 100644 --- a/integration/form-test.ts +++ b/integration/form-test.ts @@ -1102,11 +1102,7 @@ test.describe("Forms", () => { test("empty file inputs resolve to File objects on the server", async ({ page, - channel, }) => { - // TODO: Look into this test failing on windows - test.skip(channel === "msedge", "Fails on windows with undici"); - let app = new PlaywrightFixture(appFixture, page); await app.goto("/empty-file-upload"); diff --git a/package.json b/package.json index 842a2e16ea..bc7d55856d 100644 --- a/package.json +++ b/package.json @@ -94,7 +94,6 @@ "history": "^5.3.0", "isbot": "^5.1.11", "jest": "^29.6.4", - "jest-environment-jsdom": "^29.6.2", "jsonfile": "^6.1.0", "prettier": "^2.8.8", "prompts": "^2.4.2", @@ -109,7 +108,6 @@ "type-fest": "^2.19.0", "typedoc": "^0.26.11", "typescript": "^5.4.5", - "undici": "^6.10.1", "unified": "^10.1.2", "unist-util-remove": "^3.1.0", "vite": "^6.1.0", diff --git a/packages/react-router/__tests__/setup.ts b/packages/react-router/__tests__/setup.ts index 423c0fb702..59030da8b9 100644 --- a/packages/react-router/__tests__/setup.ts +++ b/packages/react-router/__tests__/setup.ts @@ -1,44 +1,6 @@ // https://reactjs.org/blog/2022/03/08/react-18-upgrade-guide.html#configuring-your-testing-environment globalThis.IS_REACT_ACT_ENVIRONMENT = true; -if (!globalThis.TextEncoder || !globalThis.TextDecoder) { - const { TextDecoder, TextEncoder } = require("node:util"); - globalThis.TextEncoder = TextEncoder; - globalThis.TextDecoder = TextDecoder; -} - -if (!globalThis.ReadableStream || !globalThis.WritableStream) { - const { ReadableStream, WritableStream } = require("node:stream/web"); - globalThis.ReadableStream = ReadableStream; - globalThis.WritableStream = WritableStream; -} - -if (!globalThis.fetch) { - const { fetch, FormData, Request, Response, Headers } = require("undici"); - - globalThis.fetch = fetch; - globalThis.Request = Request; - globalThis.Response = Response; - globalThis.Headers = Headers; - - globalThis.FormData = globalThis.FormData || FormData; -} - -if (!globalThis.TextEncoderStream) { - const { TextEncoderStream } = require("node:stream/web"); - globalThis.TextEncoderStream = TextEncoderStream; -} - -if (!globalThis.TextDecoderStream) { - const { TextDecoderStream } = require("node:stream/web"); - globalThis.TextDecoderStream = TextDecoderStream; -} - -if (!globalThis.TransformStream) { - const { TransformStream } = require("node:stream/web"); - globalThis.TransformStream = TransformStream; -} - const consoleError = console.error; console.error = (msg, ...args) => { if ( diff --git a/packages/react-router/jest.config.js b/packages/react-router/jest.config.js index dc45566ce5..7234f0b192 100644 --- a/packages/react-router/jest.config.js +++ b/packages/react-router/jest.config.js @@ -3,5 +3,5 @@ module.exports = { ...require("../../jest/jest.config.shared"), setupFiles: ["/__tests__/setup.ts"], setupFilesAfterEnv: ["@testing-library/jest-dom"], - testEnvironment: "jsdom", + testEnvironment: "jest-fixed-jsdom", }; diff --git a/packages/react-router/package.json b/packages/react-router/package.json index 4870f3403c..0bab914e71 100644 --- a/packages/react-router/package.json +++ b/packages/react-router/package.json @@ -89,6 +89,8 @@ }, "devDependencies": { "@types/set-cookie-parser": "^2.4.1", + "jest-environment-jsdom": "^29.6.2", + "jest-fixed-jsdom": "^0.0.9", "react": "^19.1.0", "react-dom": "^19.1.0", "rimraf": "^6.0.1", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index aedd225121..38c74edc51 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -170,9 +170,6 @@ importers: jest: specifier: ^29.6.4 version: 29.7.0(@types/node@20.11.30)(babel-plugin-macros@3.1.0) - jest-environment-jsdom: - specifier: ^29.6.2 - version: 29.6.2 jsonfile: specifier: ^6.1.0 version: 6.1.0 @@ -215,9 +212,6 @@ importers: typescript: specifier: ^5.4.5 version: 5.4.5 - undici: - specifier: ^6.10.1 - version: 6.20.1 unified: specifier: ^10.1.2 version: 10.1.2 @@ -744,6 +738,12 @@ importers: '@types/set-cookie-parser': specifier: ^2.4.1 version: 2.4.7 + jest-environment-jsdom: + specifier: ^29.6.2 + version: 29.6.2 + jest-fixed-jsdom: + specifier: ^0.0.9 + version: 0.0.9(jest-environment-jsdom@29.6.2) react: specifier: ^19.1.0 version: 19.1.0 @@ -6385,6 +6385,12 @@ packages: resolution: {integrity: sha512-DOSwCRqXirTOyheM+4d5YZOrWcdu0LNZ87ewUoywbcb2XR4wKgqiG8vNeYwhjFMbEkfju7wx2GYH0P2gevGvFw==} engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + jest-fixed-jsdom@0.0.9: + resolution: {integrity: sha512-KPfqh2+sn5q2B+7LZktwDcwhCpOpUSue8a1I+BcixWLOQoEVyAjAGfH+IYZGoxZsziNojoHGRTC8xRbB1wDD4g==} + 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} @@ -8427,10 +8433,6 @@ packages: resolution: {integrity: sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==} engines: {node: '>=0.6'} - tough-cookie@4.1.2: - resolution: {integrity: sha512-G9fqXWoYFZgTc2z8Q5zaHy/vJMjm+WV0AkAeHxVCQiEB1b+dGvWzFW6QV07cY5jQ5gRkeid2qIkzkxUnmoQZUQ==} - engines: {node: '>=6'} - tough-cookie@4.1.4: resolution: {integrity: sha512-Loo5UUvLD9ScZ6jh8beX1T6sO1w2/MpCRpEP7V280GKMVUQ0Jzar2U3UJPsrdbziLEMMhu3Ujnq//rhiFuIeag==} engines: {node: '>=6'} @@ -11800,7 +11802,7 @@ snapshots: '@types/jsdom@20.0.1': dependencies: '@types/node': 20.11.30 - '@types/tough-cookie': 4.0.2 + '@types/tough-cookie': 4.0.5 parse5: 7.1.2 '@types/jsdom@21.1.1': @@ -14753,6 +14755,10 @@ snapshots: jest-mock: 29.7.0 jest-util: 29.7.0 + jest-fixed-jsdom@0.0.9(jest-environment-jsdom@29.6.2): + dependencies: + jest-environment-jsdom: 29.6.2 + jest-get-type@29.6.3: {} jest-haste-map@29.7.0: @@ -14994,7 +15000,7 @@ snapshots: rrweb-cssom: 0.6.0 saxes: 6.0.0 symbol-tree: 3.2.4 - tough-cookie: 4.1.2 + tough-cookie: 4.1.4 w3c-xmlserializer: 4.0.0 webidl-conversions: 7.0.0 whatwg-encoding: 2.0.0 @@ -17452,13 +17458,6 @@ snapshots: toidentifier@1.0.1: {} - tough-cookie@4.1.2: - dependencies: - psl: 1.9.0 - punycode: 2.3.0 - universalify: 0.2.0 - url-parse: 1.5.10 - tough-cookie@4.1.4: dependencies: psl: 1.9.0