title: When to use act() in jest unit tests with react-dom
body: <p>According to the react unit testing documentation:</p>
  
  <blockquote>
    <p><strong>act()</strong></p>
    
    <p>To prepare a component for assertions, wrap the code rendering
    it and performing updates inside an act() call. This makes your test
    run closer to how React works in the browser.</p>
  </blockquote>
  
  <p>But the test runs perfectly fine in both cases:</p>
  
  <h3>Without act()</h3>
  
  <pre><code>it('Should return some text', () =&gt; {
    render(&lt;TestComponent /&gt;, container);
    expect(container.textContent).toBe('some text');
  });
  </code></pre>
  
  <h3>With act()</h3>
  
  <pre><code>it('Should return some text', () =&gt; {
    act(() =&gt; {
      render(&lt;TestComponent /&gt;, container);
    });
  
    expect(container.textContent).toBe('some text');
  })
  </code></pre>
  
  <p>The questions is: <strong>What exactly act() does, and when should someone use it?</strong></p>