title: Using Jest and Enzyme, how do I test a function passed in through props?
body: <p>Using Jest and Enzyme, how can I test if this.props.functionToTest was run?</p>
  
  <pre><code>class TestComponent extends Component {
     static propTypes = {
       functionToTest: PropTypes.func
     }
     componentDidMount() {
       this.props.functionToTest()
     }
  }
  </code></pre>
  
  <p>In Jest, I've tried creating mockProps and passing them in when mounting the component.  </p>
  
  <pre><code>let props = {
    functionToTest = jest.fn(() =&gt; {});
  }
  beforeEach(() =&gt; {
    const wrapper = mount(&lt;TestComponent {...props} /&gt;
  }
  </code></pre>
  
  <p>A console.log in the componentDidMount function shows functionToTest as undefined.  Obviously passing in the props during mount isn't working.</p>
  
  <p>Question 1:  How can I pass in mock props that will show in the componentDidMount function?</p>
  
  <p>Question 2:  Once that function is available, how do I gain access to the function so I can use spyOn or something similar to test if the function was run?</p>