title: Best practice to test propTypes with jest + enzyme + react-redux?
body: <p>I have tried many solutions I found on google to test if <code>Component.propTypes</code> was set properly at a react component, but none of them worked for me. Even though I get a console warning when running my React application on the browser if the properties are passed incorrectly, when I run jest I can't capture that warning in any way that I tried. Here is my best attempt:</p>
  
  <p>App.js:</p>
  
  <pre><code>export class App extends Component {
      constructor(props) {
          super(props);
      }
  
      render() {
          return &lt;div/&gt;;
      }
  }
  
  
  App.propTypes = {
      images: PropTypes.array.isRequired
  };
  
  function mapStateToProps(state) {
      const {images} = state;
      return {images: images};
  }
  
  export default connect(mapStateToProps)(App);
  </code></pre>
  
  <p>App.test.js:</p>
  
  <pre><code>import React from 'react';
  import chai from 'chai';
  import chaiEnzyme from 'chai-enzyme';
  import {shallow} from 'enzyme';
  import configureStore from 'redux-mock-store';
  import thunk from 'redux-thunk';
  import sinon from 'sinon'
  
  import {Provider} from 'react-redux';
  import App from './App';
  
  const expect = chai.use(chaiEnzyme()).expect
  const mockStore = configureStore([thunk]);
  
  const wrap = (initialState, props) =&gt; {
      return shallow(&lt;Provider store={mockStore(initialState)}&gt;&lt;App {...props} /&gt;&lt;/Provider&gt;)
  };
  
  describe('App container', () =&gt; {
      it('validates properties', () =&gt; {
          const stub = sinon.stub(console, 'warn');
  
          console.warn.reset();
          React.createElement(App, {});
          expect(stub.calledOnce).to.equal(true);
          expect(stub.calledWithMatch(/Failed prop type/)).to.equal(true);
  
          console.warn.restore();
      });
  
      it('renders without crashing', () =&gt; {
          wrap();
      });
  
      it('is react-redux connected', () =&gt; {
          const wrapper = wrap();
          expect(wrapper.find('Connect(App)')).to.have.length(1);
      });
  
      it('correctly maps properties', () =&gt; {
          const wrapper = wrap({images: []});
          expect(wrapper.props().images).to.equal([]);
      });
  });
  </code></pre>