title: Jest spyOn function called
body: <p>I'm trying to write a simple test for a simple React component, and I want to use Jest to confirm that a function has been called when I simulate a click with enzyme. According to the Jest docs, I should be able to use <code>spyOn</code> to do this: <a href="http://facebook.github.io/jest/docs/jest-object.html#jestspyonobject-methodname" rel="noreferrer">spyOn</a>.</p>
  
  <p>However, when I try this, I keep getting <code>TypeError: Cannot read property '_isMockFunction' of undefined</code> which I take to mean that my spy is undefined. My code looks like this:</p>
  
  <pre><code>import React, { Component } from 'react';
  import logo from './logo.svg';
  import './App.css';
  class App extends Component {
  
    myClickFunc = () =&gt; {
        console.log('clickity clickcty')
    }
    render() {
      return (
        &lt;div className="App"&gt;
          &lt;div className="App-header"&gt;
            &lt;img src={logo} className="App-logo" alt="logo" /&gt;
            &lt;h2&gt;Welcome to React&lt;/h2&gt;
          &lt;/div&gt;
          &lt;p className="App-intro" onClick={this.myClickFunc}&gt;
            To get started, edit &lt;code&gt;src/App.js&lt;/code&gt; and save to reload.
          &lt;/p&gt;
        &lt;/div&gt;
      );
    }
  }
  
  export default App;
  </code></pre>
  
  <p>and in my test file:</p>
  
  <pre><code>import React from 'react';
  import ReactDOM from 'react-dom';
  import App from './App';
  import { shallow, mount, render } from 'enzyme'
  
  describe('my sweet test', () =&gt; {
   it('clicks it', () =&gt; {
      const spy = jest.spyOn(App, 'myClickFunc')
      const app = shallow(&lt;App /&gt;)
      const p = app.find('.App-intro')
      p.simulate('click')
      expect(spy).toHaveBeenCalled()
   })
  })
  </code></pre>
  
  <p>Anyone have an insight into what I'm doing wrong?</p>