title: How to test component that contains a component connected to Redux in Enzyme / React?
body: <p>There's a familiar gotcha when testing <strong>React</strong> <strong>components</strong> that are connected to <strong>Redux</strong> in <strong>Enzyme</strong>. You may have run into this error: </p>
  
  <pre><code>Invariant Violation: Could not find "store" in either the context or props of "Connect(YourComponent)
  </code></pre>
  
  <p>This is <strong>resolved</strong> by exporting the component under test twice:</p>
  
  <pre><code>export class YourComponent extends Component {}
  export default connect(mapStateToProps, mapDispatchToProps)(YourComponent);
  </code></pre>
  
  <p>And in your test <strong>import YourComponent as an object</strong>:</p>
  
  <pre><code>import { YourComponent } from '../pathToYourComponent'
  </code></pre>
  
  <p>I've run into a novel scenario regarding this issue.
  I'm testing a connected component, and I'm using the solution above to resolve that issue, however inside that component there is another connected component that gets rendered when certain props are present.</p>
  
  <pre><code>import React, { Component } from 'react';
  export class YourComponent extends Component {
    constructor(props) {
      super(props)
    }
    render() {
      const { arrayOfObjects } = this.props;
  
      let nestedConnectedComponent; 
      if (arrayOfObjects.length) {
        nestedConnectedComponent = arrayOfObjects.map((ele, idx) =&gt; (
          &lt;NestedConnectedComponent
            key={idx}
          /&gt;
        ))
      }
      return (
        &lt;div&gt; {arrayOfObjects} &lt;/div&gt;
      )
    }
  }
  
  function mapStateToProps(){}
  function mapDispatchToProps(){}
  
  export default connect(mapStateToProps, mapDispatchToProps)(YourComponent);
  </code></pre>
  
  <p>How do you avoid the "could not find store" error when you are testing a component that contains a component that is connected to redux?</p>
  
  <p>The component is being <strong>shallow</strong> rendered in the latest version of Enzyme. </p>