-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Can't pass Material-UI muiTheme in context #778
Comments
Context won't be passed unless a component has |
Thanks a lot and sorry that this definitely isn't an issue. It might be helpful though to others, while this doesn't look to be very well documented. |
(note that this isn't specific to enzyme, this is how react itself works) |
@vladblindu here's the React doc page on context: https://facebook.github.io/react/docs/context.html |
I answered before even checking, because I was sure I missed something, but now I realise has contextTypes defined. In fact it looks like this:
So, it has to be something else.
Still no context. |
Try passing the context in |
Now I can see the context in |
@vladblindu Does |
TextField is a material-ui component and is defining contextTypes with muiTheme as required.
|
OK, let's step back. If you're getting React errors in your browser console, it's an issue with your own code, not with enzyme. Do you have an issue with enzyme? |
It looks like I have. I run the mocha test from WebStorm.(so it's WebStomr's console) Somehow it looks like enzyme's shallow render function does'n pass the context down the chain. |
Thank you for your time. This stack-overflow question sent me on the wrong track. http://stackoverflow.com/questions/38264715/how-to-pass-context-down-to-the-enzyme-mount-method-to-test-component-which-incl. Especially this comment http://stackoverflow.com/questions/38264715/how-to-pass-context-down-to-the-enzyme-mount-method-to-test-component-which-incl#comment65256968_38295396 |
|
My input locker component adds a FloatingActionButton on the right side of it's child () disabling or enabling it. It don't paste the code here for the sake of brevity.
The component works perfectly in the browser.
I tried this:
I dropped a console.log(context) in the InputLocker's constructor. It prints:
I wrapped everithing in a a . Same result.
I'm not a "pro" so I might miss something but after 3 days of googling and banging my head against the wall, I decided to open another issue here.
The text was updated successfully, but these errors were encountered: