Skip to content

Commit 3fb632a

Browse files
committed
web: fix ReferenceError after React Router v7 migration
After migrating to React Router v7, the test suite fails with the following error: > ReferenceError: TextEncoder is not defined This appears to be due to an unimplemented TextEncoder in jsdom. To resolve this, we follow the same workaround as React Router, as outlined in remix-run/react-router#12363 (comment)
1 parent 706160d commit 3fb632a

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

web/src/setupTests.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,11 @@
33
// expect(element).toHaveTextContent(/react/i)
44
// learn more: https://github.com/testing-library/jest-dom
55
import "@testing-library/jest-dom";
6+
import { TextDecoder, TextEncoder } from "util";
7+
8+
globalThis.IS_REACT_ACT_ENVIRONMENT = true;
9+
10+
if (!globalThis.TextEncoder || !globalThis.TextDecoder) {
11+
globalThis.TextEncoder = TextEncoder;
12+
globalThis.TextDecoder = TextDecoder;
13+
}

0 commit comments

Comments
 (0)