title: How to test getDerivedStateFromProps with Jest and Enzyme
body: <p>I have this simple code that is using the new <code>getDerivedStateFromProps</code> lifecycle:</p>
  
  <pre><code>static getDerivedStateFromProps(nextProps: Props, prevState: State) {
    if (nextProps.value !== prevState.value) {
      console.log('hello');
      return {
        value: nextProps.value
      };
    }
  
    return null;
  }
  </code></pre>
  
  <p>And this is the test:</p>
  
  <pre><code>it('should call getDerivedStateFromProps', () =&gt; {
    const instance = shallow(mockComponent());
  
    instance.setProps({ value: 'test2' });
  
    expect(instance.state.value).toEqual('test2');
  });
  </code></pre>
  
  <p>But I have this error but I know that is calling because of the console.log().</p>
  
  <pre><code>Expected value to equal:
    "test2"
  Received:
    undefined
  </code></pre>
  
  <p>How do I test properly <code>getDerivedStateFromProps</code>?</p>
  
  <p>I'm using:</p>
  
  <pre><code>react: 16.4
  react-Dom: 16.4
  enzyme-adapter-react-16: 1.1.1
  react-test-renderer: 16.4.1
  </code></pre>