title: How to test with Jest that ReactDOM.render has been called when it has been wrapped in a conditional?
body: <p>I have the following react component and it conditionally calls <code>ReactDOM.render</code> if <code>root === true</code> in order to satisfy <code>flow</code>:</p>
  
  <pre><code>import React from 'react'
  import ReactDOM from 'react-dom'
  
  import App from './App'
  
  const root = document.getElementById('root')
  
  if (root !== null) {
    ReactDOM.render(&lt;App /&gt;, root)
  }
  </code></pre>
  
  <p>The problem is that this test no longer equals true, presumably because the conditional wrapping needs to be mocked as true or something but I can't figure it out.</p>
  
  <pre><code>import ReactDOM from 'react-dom'
  
  jest.mock('react-dom')
  
  require('../index')
  
  test('Renders the application', () =&gt; {
    expect(ReactDOM.render).toBeCalled()
  })
  </code></pre>
  
  <p>How do I need to update my test to check that <code>ReactDOM.render</code> is called?</p>