-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Test: replace Enzyme with React Testing Library #12539
Test: replace Enzyme with React Testing Library #12539
Conversation
CLA Signature Action: Thank you for your submission, we really appreciate it. We ask that you read and sign our Contributor License Agreement before we can accept your contribution. You can sign the CLA by just by adding a comment to this pull request with this exact sentence:
By commenting with the above message you are agreeing to the terms of the CLA. Your account will be recorded as agreeing to our CLA so you don't need to sign it again for future contributions to this repository. 0 out of 1 committers have signed the CLA. |
|
||
Enzyme.configure({ adapter: new Adapter() }); | ||
global.TextEncoder = TextEncoder; | ||
global.TextDecoder = TextDecoder; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be possible to explain the reason for modifying these global variables? (TextEncoder & TextDecoder)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-
Enzyme rarely needs
TextEncoder
andTextDecoder
as it's focused on React component testing, which typically doesn’t involve these APIs. With a properly configured jsdom or browser-like environment, they might already be polyfilled. Most Enzyme use cases don’t rely on text encoding/decoding. -
But in case of RNTL, Jest needs TextEncoder and TextDecoder because it runs in a Node.js environment, which doesn’t include these browser-native APIs. Even with jsdom, these specific features aren't implemented. Adding them globally ensures compatibility with libraries or code that depend on text encoding/decoding.
-
Without using
global.TextEncoder
andglobal.Decoder
getting this particular issue
https://stackoverflow.com/questions/68468203/why-am-i-getting-textencoder-is-not-defined-in-jest
Hi @tusharnagar17 , Thank you for taking the time to help us. I have left a comment on your PR. Could you please complete the CLA Signature Action so that we can accept your contributions? Additionally, as per our contributor guidelines, it would be very helpful if you could break this PR into smaller, more manageable PRs. This will make it easier for us to review and test your contributions, as the current PR does not adhere to these guidelines. In case of any questions, don't hesitate to reach out. Thank you for your understanding! |
Hi @MarioAslau, Thank you for the feedback. Kindly disregard this current pull request, and I’ll submit a new one shortly. |
Description
Replaced Enzyme usage with React Testing Library in the following files:
TypeError: _reactNative.DeviceEventEmitter.removeListener is not a function
Related issues
Fixes: #12300
Manual testing steps
yarn test filename.test.tsx -t "DescribeText ItText"
Screenshots/Recordings
Before
After
Pre-merge author checklist
Pre-merge reviewer checklist