Skip to content
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

Latest version 7.1.0 appears to break tests using enzyme #3927

Open
jimmyzhen opened this issue Dec 5, 2024 · 4 comments
Open

Latest version 7.1.0 appears to break tests using enzyme #3927

jimmyzhen opened this issue Dec 5, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@jimmyzhen
Copy link

jimmyzhen commented Dec 5, 2024

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

@jimmyzhen jimmyzhen added the bug Something isn't working label Dec 5, 2024
@mcollina
Copy link
Member

mcollina commented Dec 5, 2024

Thanks for reporting!

Can you provide steps to reproduce? We often need a reproducible example, e.g. some code that allows someone else to recreate your problem by just copying and pasting it. If it involves more than a couple of different file, create a new repository on GitHub and add a link to that.

@KhafraDev
Copy link
Member

I've never used enzyme, but this seems similar to enzymejs/enzyme#2524 (comment)

@jimmyzhen
Copy link
Author

@mcollina I created a repo for you to reproduce the reported test error. Please let me know if you have any questions.

@mcollina
Copy link
Member

Your repository uses https://github.com/wojtekmaj/enzyme-adapter-react-17, which is archived and not maintained anymore. My guess is that old module does not support those globals (TextDecoder). I would recommend to update your dependencies.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants