title: Run useEffect hook before rendering jest snapshot in react-test-renderer test
body: <p>Let's say I have the following basic component called <code>Basic.js</code>:</p>
  
  <pre><code>import React, { useState, useEffect } from 'react';
  
  export default () =&gt; {
    const [items, setItems] = useState([{ name: 'original' }]);
  
    useEffect(() =&gt; {
      setItems([{ name: 'new1' }, { name: 'new2' }]);
    }, []);
  
    return (
      &lt;div&gt;{items &amp;&amp; items.map((item, i) =&gt; &lt;div key={i}&gt;{item.name}&lt;/div&gt;)}&lt;/div&gt;
    );
  };
  </code></pre>
  
  <p>Using <a href="https://www.npmjs.com/package/react-test-renderer" rel="nofollow noreferrer">react-test-renderer</a>, I can write the following test:</p>
  
  <pre><code>import React from 'react';
  import TestRenderer from 'react-test-renderer';
  import Basic from './Basic';
  
  describe('Basic', () =&gt; {
    test('renders', async done =&gt; {
      let component = TestRenderer.create(&lt;Basic /&gt;);
      setImmediate(() =&gt; {
        expect(component.toJSON()).toMatchSnapshot();
        done();
      });
    });
  });
  </code></pre>
  
  <p>Which generates the following jest snapshot when I run <code>npm test</code>:</p>
  
  <pre><code>exports[`Basic renders 1`] = `
  &lt;div&gt;
    &lt;div&gt;
      original
    &lt;/div&gt;
  &lt;/div&gt;
  `;
  </code></pre>
  
  <p>How can I write the test so the <code>useEffect</code> hook is run and reflected in the snapshot? So the generated snapshot looks like this:</p>
  
  <pre><code>exports[`BasicClass renders 1`] = `
  &lt;div&gt;
    &lt;div&gt;
      new1
    &lt;/div&gt;
    &lt;div&gt;
      new2
    &lt;/div&gt;
  &lt;/div&gt;
  `;
  </code></pre>
  
  <p>Is this isn't possible, is there a testing library I can use to run this hook?</p>