title: jest + enzyme, using mount(), document.getElementById() returns null on component which appear after _method call
body: <p>I faced a problem with my jest+enzyme <code>mount()</code> testing. I am testing a function, which switches displaying components. </p>
  
  <p>Switch between components: when <code>state.infoDisplayContent = 'mission'</code> a <code>missionControl</code> component is mounted, when <code>state.infoDisplayContent = 'profile'</code> - other component steps in: </p>
  
  <pre><code>_modifyAgentStatus () {
      const { currentAgentProfile, agentsDatabase } = this.state;
      const agentToMod = currentAgentProfile;
  
      if (agentToMod.status === 'Free') {
          this.setState({
              infoDisplayContent: 'mission'
          });
          agentToMod.status = 'Waiting';
      } else if (agentToMod.status === 'Waiting') {
          const locationSelect = document.getElementById('missionLocationSelect');
  
          agentToMod.location = locationSelect[locationSelect.selectedIndex].innerText;
          agentToMod.status = 'On Mission';
          this.setState({
              infoDisplayContent: 'profile'
          });
      }
  }
  </code></pre>
  
  <p>When I trigger this function everything looks Ok, this test runs well and test successfully pass with required component:</p>
  
  <pre><code>import React from 'react';
  import { mount } from 'enzyme';
  import App from '../containers/App';
  
  const result = mount(
      &lt;App /&gt;
  )
  
  test('change mission controls', () =&gt; {
      expect(result.state().currentAgentProfile.status).toBe('Free');
      result.find('#statusController').simulate('click');
      expect(result.find('#missionControls')).toHaveLength(1);
      expect(result.find('#missionLocationSelect')).toHaveLength(1);
      expect(result.state().currentAgentProfile.status).toBe('Waiting');
  });
  
  But when I simulate onClick two times: 
  
  test('change mission controls', () =&gt; {
      expect(result.state().currentAgentProfile.status).toBe('Free');
      result.find('#statusController').simulate('click');
      expect(result.find('#missionControls')).toHaveLength(1);
      expect(result.find('#missionLocationSelect')).toHaveLength(1);
      expect(result.state().currentAgentProfile.status).toBe('Waiting');
      result.find('#statusController').simulate('click');
      expect(result.state().currentAgentProfile.status).toBe('On Mission');
  });
  </code></pre>
  
  <p>I get this assert: </p>
  
  <pre><code>    TypeError: Cannot read property 'selectedIndex' of null
  
    at App._modifyAgentStatus (development/containers/App/index.js:251:68)
    at Object.invokeGuardedCallback [as invokeGuardedCallbackWithCatch] (node_modules/react-dom/lib/ReactErrorUtils.js:26:5)
    at executeDispatch (node_modules/react-dom/lib/EventPluginUtils.js:83:21)
    at Object.executeDispatchesInOrder (node_modules/react-dom/lib/EventPluginUtils.js:108:5)
    at executeDispatchesAndRelease (node_modules/react-dom/lib/EventPluginHub.js:43:22)
    at executeDispatchesAndReleaseSimulated (node_modules/react-dom/lib/EventPluginHub.js:51:10)
    at forEachAccumulated (node_modules/react-dom/lib/forEachAccumulated.js:26:8)
    at Object.processEventQueue (node_modules/react-dom/lib/EventPluginHub.js:255:7)
    at node_modules/react-dom/lib/ReactTestUtils.js:350:22
    at ReactDefaultBatchingStrategyTransaction.perform (node_modules/react-dom/lib/Transaction.js:140:20)
    at Object.batchedUpdates (node_modules/react-dom/lib/ReactDefaultBatchingStrategy.js:62:26)
    at Object.batchedUpdates (node_modules/react-dom/lib/ReactUpdates.js:97:27)
    at node_modules/react-dom/lib/ReactTestUtils.js:348:18
    at ReactWrapper.&lt;anonymous&gt; (node_modules/enzyme/build/ReactWrapper.js:776:11)
    at ReactWrapper.single (node_modules/enzyme/build/ReactWrapper.js:1421:25)
    at ReactWrapper.simulate (node_modules/enzyme/build/ReactWrapper.js:769:14)
    at Object.&lt;anonymous&gt; (development/tests/AgentProfile.test.js:26:38)
    at process._tickCallback (internal/process/next_tick.js:109:7)
  </code></pre>
  
  <p>It is obvious that:</p>
  
  <pre><code>document.getElementById('missionLocationSelect');
  </code></pre>
  
  <p>return null, but I can not get why. Element passes tests, as I mention.</p>
  
  <pre><code>expect(result.find('#missionLocationSelect')).toHaveLength(1);
  </code></pre>
  
  <p>But it could not be captured with <code>document.getElementById()</code>.</p>
  
  <p>Please, help me to fix this problem and run tests.</p>