title: When testing a React component, is there any way to directly call its non-lifecycle methods?
body: <p>I'm using Jest, and I have some component like:</p>
  
  <pre><code>var TestClass = react.createClass({
    foo: function() {
      return "test";
    },
    render: function() {
      return &lt;div /&gt;;
    }
  });
  </code></pre>
  
  <p>And I want to write a unit test specifically for <code>TestClass</code>' <code>foo</code> method.</p>
  
  <p>I saw that <a href="https://stackoverflow.com/questions/31612598/call-a-react-component-method-from-outside">Call a React component method from outside</a> suggested this should be possible - simply render the component in the test and call it:</p>
  
  <pre><code>describe("TestClass", function() { 
      it("should access internal methods", function() { 
      var test = &lt;TestClass /&gt;
  
      expect(test.foo()).toBeTruthy()
    }
  });
  </code></pre>
  
  <p>From that question's answer I would expect this test to pass, but instead: </p>
  
  <blockquote>
    <p>test.foo is not a function</p>
  </blockquote>
  
  <p>Have I misunderstood that answer? </p>
  
  <p>In general I would prefer to be able to test non-lifecycle methods in this manner - it would give better granularity, but if this is not possible, is there a sane alternative? </p>
  
  <p>For example how might one test a method passed as props to a component's child without this ability?</p>