-
-
Notifications
You must be signed in to change notification settings - Fork 15.3k
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
Explain unit testing decorated components. #607
Conversation
Using the babelhook file is more flexible because it allows configuration such as setting the experimental stage.
Wouldn't |
Exporting a Babel handles the interchangeable use of ES6 The reason why it's relevant is that people might be using ES6 modules + Babel to build their front-end code, but still use CommonJS format in testing or server-side code/rendering. So the same component might be consumed in several places through different module systems. Right now in their CJS side ES6 is the clear winner long term and the suggested testing technique is very valuable, however there should be a note warning people that if they use CommonJS to require ES6 Redux smart components, then they should explicitely access it via |
This reverts commit ed32232.
Explain unit testing decorated components.
This is in, thanks |
Yesterday I had a chat with someone suggesting to simply unwrap the decorated component instead. He suggested using something like this to recursively unwrap it and use that in unit tests: function unwrap(component) {
return component.wrapped ? unwrap(component.wrapped) : component;
} I haven't tried this approach myself yet, but it seems a bit cleaner than having multiple exports, especially since you don't have to change your application sources to support your unit tests. How do you guys feel about this? |
That would need every HOC to converge on the same property name. In reality I think it works worse than just exporting vanilla stuff. |
Also improved test setup a bit using a babelhook file rather than a command line option, for more flexibility.