-
Notifications
You must be signed in to change notification settings - Fork 22
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
Migrate from Enzyme to React Testing Library #1197
Comments
Thanks for putting this together! I think switching to RTL probably makes sense as our teams are likely already familiar with it, even with some of the caveats that might exist in RTL. A couple of questions/thoughts:
I don't want to scope creep here as this will already be a fairly large undertaking, but I would be curious how much effort the above might add vs the benefit. |
There is a list of components to do test migrations with here: #1159 |
I'm a fan of tests in their component folders, but we can also leave the tests in the Related, if a component test file has 5 tests and we update functionality for that component, should the new test be written using RTL in the same file or should the entire file be converted to RTL in addition to the new test? This could allow someone to only focus on the new code and leave other test rewrites for a separate PR.
Are you saying that when I want to rewrite tests for a component to RTL I also need to add TypeScript types for that component or components? |
I think my vote would be to convert the test to use RTL. I do realize that will tack on additional work for someone making a small change to a component, but without fulltime dedicated resources to Cauldron, I think we need to try to make gains wherever we can.
The test itself should be written in typescript, hopefully this wouldn't require changing any component typescript types and might expose issues where something was typed incorrectly. |
Thinking out loud: we did a conversion of all the documentation from custom React documentation to MDX starting in mid-March, with the final conversion completed mid-August, so roughly ~5 months. Assuming that converting tests takes roughly the same amount of time as documentation, it is possible that we could have all tests converted over to RTL by end of Q1 2024 if we were to start in October. If we could borrow some resources from teams, this could go faster - just trying to get a rough time frame out there of what kind of scope we're looking at. |
I'm not sure if this is a fair comparison but I looked at some of the largest test files and compared it to the lines of code in the docs file. Looking through all of the test files, there are more test files under 100 lines that would be quicker to migrate, but I can imagine the ones below taking more effort.
|
Maybe not, I'm just trying to put some ballpark figure out there to work with. We can pad it accordingly once I can figure out if there's additional resources we can lean on. |
👍 from me! |
👍 |
1 similar comment
👍 |
Closing this issue since the initial setup has been completed. We'll track migrating each component in #1159. |
Background
In order to update Cauldron to React 18, we need to update our testing framework. Currently, Enzyme does not support React 17 or React 18.
Related resources:
https://dev.to/wojtekmaj/enzyme-is-dead-now-what-ekl
https://stackoverflow.com/questions/72029189/does-enzyme-support-react-version-18
Recommendations
✨ Switching to React Testing Library
Pros
Cons
In this branch https://github.com/dequelabs/cauldron/tree/rfc--testing-library, I've used the matching React Testing Library to the React version 16.3.1 and updated the tests for the Button component as a proof of concept. We can run Enzyme and RTL together until we finish all of the test migrations.
Migration Plan
https://testing-library.com/docs/react-testing-library/migrate-from-enzyme
packages/react/__test__/src/components/**/index.js
topackages/react/src/components/**/*.test.tsx
@scurker has mentioned in the past about trying out Playwright Component Testing.
Pros
Cons
Additional resources:
https://github.com/microsoft/playwright/tree/main/packages/playwright-ct-react
https://www.lambdatest.com/learning-hub/playwright-component-testing
The text was updated successfully, but these errors were encountered: