Skip to content

Commit ce82034

Browse files
committed
Update testing setup
1 parent a7dd779 commit ce82034

File tree

4 files changed

+6
-73
lines changed

4 files changed

+6
-73
lines changed

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@
7878
"@types/wait-on": "^5.3.2",
7979
"@typescript-eslint/eslint-plugin": "^7.5.0",
8080
"@typescript-eslint/parser": "^7.5.0",
81-
"abort-controller": "^3.0.0",
8281
"babel-jest": "^29.7.0",
8382
"babel-plugin-dev-expression": "^0.2.3",
8483
"babel-plugin-transform-remove-console": "^6.9.4",

packages/react-router/__tests__/router/router-memory-test.ts

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -211,36 +211,4 @@ describe("a memory router", () => {
211211

212212
router.dispose();
213213
});
214-
215-
it("throws on submitting FormData when it's not available", async () => {
216-
if (global.FormData) {
217-
// This is globally available in Node 18, this test is primarily for Node 16
218-
// eslint-disable-next-line jest/no-conditional-expect
219-
expect(true).toBe(true);
220-
return;
221-
}
222-
223-
let actionSpy = jest.fn();
224-
225-
let router = createRouter({
226-
routes: [
227-
{
228-
path: "/",
229-
action: actionSpy,
230-
},
231-
],
232-
history: createMemoryHistory(),
233-
});
234-
235-
await expect(() =>
236-
router.navigate("/", {
237-
formMethod: "post",
238-
body: { key: "value" },
239-
})
240-
).rejects.toThrowErrorMatchingInlineSnapshot(
241-
`"FormData is not available in this environment"`
242-
);
243-
244-
router.dispose();
245-
});
246214
});
Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
11
// https://reactjs.org/blog/2022/03/08/react-18-upgrade-guide.html#configuring-your-testing-environment
22
globalThis.IS_REACT_ACT_ENVIRONMENT = true;
33

4-
if (!globalThis.fetch) {
4+
if (!globalThis.TextEncoder || !globalThis.TextDecoder) {
55
const { TextDecoder, TextEncoder } = require("node:util");
6-
globalThis.TextDecoder = TextDecoder;
76
globalThis.TextEncoder = TextEncoder;
7+
globalThis.TextDecoder = TextDecoder;
8+
}
89

10+
if (!globalThis.ReadableStream || !globalThis.WritableStream) {
911
const { ReadableStream, WritableStream } = require("node:stream/web");
1012
globalThis.ReadableStream = ReadableStream;
1113
globalThis.WritableStream = WritableStream;
14+
}
1215

16+
if (!globalThis.fetch) {
1317
const { fetch, FormData, Request, Response, Headers } = require("undici");
1418

1519
globalThis.fetch = fetch;
@@ -20,17 +24,6 @@ if (!globalThis.fetch) {
2024
globalThis.FormData = globalThis.FormData || FormData;
2125
}
2226

23-
if (!globalThis.AbortController) {
24-
const { AbortController } = require("abort-controller");
25-
globalThis.AbortController = AbortController;
26-
}
27-
28-
if (!globalThis.TextEncoder || !globalThis.TextDecoder) {
29-
const { TextDecoder, TextEncoder } = require("node:util");
30-
globalThis.TextEncoder = TextEncoder;
31-
globalThis.TextDecoder = TextDecoder;
32-
}
33-
3427
if (!globalThis.TextEncoderStream) {
3528
const { TextEncoderStream } = require("node:stream/web");
3629
globalThis.TextEncoderStream = TextEncoderStream;
@@ -40,13 +33,3 @@ if (!globalThis.TransformStream) {
4033
const { TransformStream } = require("node:stream/web");
4134
globalThis.TransformStream = TransformStream;
4235
}
43-
44-
if (!globalThis.File) {
45-
const { File } = require("undici");
46-
globalThis.File = File;
47-
}
48-
49-
if (!globalThis.crypto) {
50-
const { webcrypto } = require("node:crypto");
51-
globalThis.crypto = webcrypto;
52-
}

pnpm-lock.yaml

Lines changed: 0 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)