You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
classNotGonnaReadextendsComponent{render(){return(<p>My favorite color is {this.context.favoriteColor}</p>);}}classWillReadextendsComponent{render(){return(<p>My favorite color is {this.context.favoriteColor}</p>);}}WillRead.contextTypes={favoriteColor: PropTypes.string,}classFavoriteColorProviderextendsComponent{getChildContext(){return{favoriteColor: 'purple',};}}
This is probably related to #664 - but may also be distinct.
It's possible that enzyme isn't filtering context by contextTypes, but I'd also expect React to do that for us. Can you check in react 15, and see if the same thing occurs? (also in mount on both 15 and 16)
This was fixed in facebook/react#11922. It was released in react-test-renderer v16.3. So I'm going to open a PR shortly that will fix it on enzyme's side for react@<16.3.
Consider the following, simplified example:
If we render it like so:
then the output is going to be
My favorite color is
.Rendering this, however:
If we render it like so:
will correctly output
My favorite color is purple
.Current behavior
If we would like to test if NotGonnaRead component is behaving properly (which it isn't), we would need to do something along the lines:
This will render
<p>My favorite color is purple</p>
.Expected behavior
This example should render
<p>My favorite color is </p>
as contextTypes are not correctly defined.Your environment
API
Version
Adapter
The text was updated successfully, but these errors were encountered: