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

Goals and usage of test-utils are unclear in docs #11183

Closed
1 task done
nickserv opened this issue Apr 30, 2018 · 5 comments
Closed
1 task done

Goals and usage of test-utils are unclear in docs #11183

nickserv opened this issue Apr 30, 2018 · 5 comments
Assignees
Labels

Comments

@nickserv
Copy link

nickserv commented Apr 30, 2018

  • I have searched the issues of this repository and believe that this is not a duplicate.

I'm trying to use material-ui@next with react-testing-library, which does not use Enzyme, and I find the purpose and use cases of test-utils unclear in the userspace docs. I have used Enzyme previously so I understand the difference between mount/shallow/render, but not how they differ from Enzyme, as I can successfully unit test components with Enzyme directly. Meanwhile, it seems like testing libraries like react-testing-library, which do not use Enzyme renderers, cannot be used with the built in test-utils. I would appreciate more information on what test-utils do differently from a practical perspective (not just adding context to components or wrapping Enzyme for installation convenience) so I can decide when I need to use them over a different testing library.

@oliviertassinari
Copy link
Member

oliviertassinari commented Apr 30, 2018

@nickmccurdy The test-utils we are exposing are highly optional. Their only purposes is to share the internal tool we are using, it's highly dependant on enzyme. People asking this question will be better off not using it. It's targeting people how have experienced pain with Enzyme. Our helpers come with some enhancements over what enzyme is exposing by default: the untilSelector option, the dive option, the cleanUp logic, the get classes logic. There is definitely room for improvement with these modules.

You should be able to use react-testing-library independently. Given the market share of the library, it's too soon to do any specific effort for it. But if you seen improvement opportunities, let us know :).

@nickserv
Copy link
Author

nickserv commented May 5, 2018

Thanks for the update. While these changes add a little detail to what API is provided, I'm still unclear of the overall practical differences of this over Enzyme and when I should use this instead. Are the APIs provided specific to Material UI's custom solution, adding some utility helpers to Enzyme that are project agnostic but were useful in the internal helping suite, or both? If this isn't intended to be used externally, it may help to hide the page or move it to contributing docs.

@oliviertassinari
Copy link
Member

The documented helpers aren't Material-UI specific. I'm using them on my projects. I have no ambition with them. If you don't see the value they bring. It's fine, don't use them.

@nickserv
Copy link
Author

nickserv commented May 5, 2018

Thanks, I was under the impression that they were somehow required or I would at least be shooting myself in the foot with incompatibility if I didn't.

@oliviertassinari
Copy link
Member

Most of the value of our helpers come from:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants