-
-
Notifications
You must be signed in to change notification settings - Fork 10.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug]: ReferenceError: TextEncoder is not defined #12363
Comments
What versions of Node, jest, and jsdom are you using? It sounds like you have something out of date. |
I'm using:
Let me try upgrading Node.js from 20 to 22 Update 1: upgrading Node.js didn't fix it, but I noticed that Update 2: I tried upgrading $ npm ls jsdom
└─┬ jest-environment-jsdom@30.0.0-alpha.6
├─┬ @jest/environment-jsdom-abstract@30.0.0-alpha.6
│ └── jsdom@25.0.1
└── jsdom@22.1.0 Update 3: I set package.json |
It looks like jsdom doesn't implement TextEncoder yet, but there is a PR out there for it. In the meantime, you can use the same workarounds we do in our test setup. |
* build: update react-router-dom to 7.0.1 * fix: rename react-router-dom to react-router * build: replace react-router-dom 6 with react-router 7 * test: work around ReferenceError: TextEncoder is not defined See remix-run/react-router#12363 * fix: suppress false positive linter error on globalThis
Hey @timdorr , jsdom has closed the PR as "wontfix" (see jsdom/jsdom#3791 (comment)). Can we fix this here, then? And until then, can we please reopen this issue so people find this easier? |
What version of React Router are you using?
7.0.1
Steps to Reproduce
remarkablemark/mui-template#1082
I tried replacing
react-router-dom
withreact-router
but got the same errorExpected Behavior
Jest tests pass with latest
react-router
versionActual Behavior
Jest tests failing with error:
The text was updated successfully, but these errors were encountered: