Latest version `7.1.0` appears to break tests using `enzyme`
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 7.7k
- Forks
- 880
- Avg merge
- 2d 16h
- Merged PRs (30d)
- 68
Description
Bug Description
When running tests using enzyme in CRA app, the following error occurred:
Test suite failed to run
ReferenceError: TextEncoder is not defined
> 1 | import { configure } from 'enzyme';
| ^
at Object.<anonymous> (node_modules/undici/lib/web/fetch/data-url.js:5:17)
at Object.<anonymous> (node_modules/undici/lib/web/fetch/util.js:7:97)
at Object.<anonymous> (node_modules/undici/lib/web/fetch/headers.js:11:5)
at Object.<anonymous> (node_modules/undici/lib/web/fetch/response.js:3:90)
at Object.<anonymous> (node_modules/undici/lib/web/fetch/index.js:11:5)
at Object.<anonymous> (node_modules/undici/index.js:106:19)
at Object.<anonymous> (node_modules/cheerio/src/index.ts:24:1)
at Object.<anonymous> (node_modules/enzyme/src/Utils.js:9:1)
at Object.<anonymous> (node_modules/enzyme/src/ReactWrapper.js:4:1)
at Object.<anonymous> (node_modules/enzyme/src/index.js:1:1)
at Object.<anonymous> (src/setupTests.js:1:1)
Reproducible By
See https://github.com/jimmyzhen/undici-code-example
Expected Behavior
The same tests didn't break when I ran them in my environment last week, and undici v7.1.0 appears to just be just released couple of days ago.
Logs & Screenshots
Environment
node 20.11.0
enzyme 3.11.0
Additional context
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the undici/lib/web/fetch/data-url.js stack entry and the reproduction linked in the issue, then inspect how undici v7.1.0 is loaded from src/setupTests.js in the CRA example. Confirm the failure on Node 20.11.0 with enzyme 3.11.0, and consider the issue done when the test suite runs without the TextEncoder error while preserving supported runtime behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, nodejs
- Domain
- networking
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100