-
-
Notifications
You must be signed in to change notification settings - Fork 32.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
[test] Migrate tests from enzyme to react-testing-library #22911
Comments
@oliviertassinari can I pick some of the tests and migrate it react-testing-library |
@oliviertassinari Can I give it a shot at migrating any of these files? |
Need help in testing The following test depends on querying the |
@itamar244 I'm also trying to find a solution for that, the other tests have the same "find component" query |
Introduce a way for describeConformance to use react-teating-library and convert accordion.test.js to use react-testing-library
Introduce a way for describeConformance to use react-teating-library and convert accordion.test.js to use react-testing-library
@oliviertassinari how do you want to handle tests that use |
@NMinhNguyen Best to ask @eps1lon. I have ported a few of them to rtl on the data grid, but that won't cut it. |
🤔 I was wondering this myself, I took a stab at forking That basically makes it opt-in per component. If this is an approach we want I'm happy to clean that code up and push through a seperate PR for The other option we have is to duplicate those tests across components. |
@nicholas-l Yes, thanks for raising it. I have added them to the list. I think that we should move them to the corresponding components. |
@oliviertassinari Do you mean into the same file as the unit tests or move the file to |
@nicholas-l Well, forget about it, let's solve one problem at the time. |
This comment has been minimized.
This comment has been minimized.
Is it really necessary to test "props inheritance"? Isn't that kind of implied by using React? Or am I missing some point here? |
@deiga Yes, it's necessary, a component can break the inheritance. |
I don't think that's a useful discussion to have. You can always argue like "isn't that implied by JS". If we would rely on "implied by React" then we'd actually use enzyme and not testing-library.
We use tests to generate documentation. We actually solve two problems at once: maintaining documentation and testing implementation. While outdated documentation isn't that bad of a problem to have it's always annoying to deal with (outdated docs being around, issue being reported, someone has to fix it etc). I don't understand why it's so important to you that we ban The main problem with |
Sure, that makes sense 👍 I usually like to push extra hard to get rid of "too many" dependencies, and wanted to prod the reasoning behind keeping |
May I claim migrating one of the remaining components, say |
Same here, I would like to migrate |
Definitely, you can go ahead :) |
@Avi98 are you still doing |
I'm having a harder time with migrating Migrated the following unit test, but describe('prop: PopoverClasses', () => {
it('should be able to change the Popover style', () => {
const { container } = render(<Menu {...defaultProps} PopoverClasses={{ paper: 'bar' }} />);
expect(container.firstChild).to.have.class('bar');
});
}); 1) <Menu />
prop: PopoverClasses
should be able to change the Popover style:
TypeError: Cannot read property 'classList' of null
at Proxy.<anonymous> (node_modules/chai-dom/chai-dom.js:80:10)
at Proxy.methodWrapper (node_modules/chai/lib/chai/utils/addMethod.js:57:25)
at Context.<anonymous> (packages/material-ui/src/Menu/Menu.test.js:105:7)
at processImmediate (node:internal/timers:462:21) |
Would this be an appropriate solution for testing the Modal Backdrop Fade transition with testing-library? As other people have suggested, I'm not sure there is a more elegant way of doing it with testing-library.
|
Update on drawer.test.js - because this component uses the modal component it is hard to test with react-testing library and so I haven't proceeded. I'm guessing this is the reason it was left until now |
Still have tests using |
The remaining tests either need Thanks everybody for your help. This will help alot during the React 18 pre-release. |
15 months ago, we have introduced react-testing-library in the codebase: #15732. Since, then, we have been progressively migrating the tests from enzyme to react-testing-library. This was done as a background task, so far. Especially when we were migrating a component from class names to hooks or when we needed to fix a bug.
However, we have seen community members interested in helping with this effort, e.g. @baterson in #22441, @marcosvega91 in #20914, @emilyuhde in #17942, or @eladmotola in #22906.
I have opened this issue so we can keep track of the tests that are left to be migrated and avoid conflicts:
createMount()
usageIntegration
The text was updated successfully, but these errors were encountered: