title: Calling setState in jsdom-based tests causing "Cannot render markup in a worker thread" error
body: <p>I'm testing my React components under <a href="https://github.com/tmpvar/jsdom">jsdom</a> using <a href="https://github.com/ikr/jsdom-test-browser">my own tiny "virtual browser" utility.</a> Works just fine, until I'm trying to <code>setState</code>. For example, when testing a children ages input control:</p>
  
  <pre><code>describe('rendering according to the draft value', function () {
      var component;
  
      beforeEach(function () {
          component = TestUtils.renderIntoDocument(
              React.createElement(ChildrenInput, {value: []})
          );
  
          component.setState({draft: [{age: null}, {age: null}]}, done);
      });
  
      it('overrides the value property for the count', function () {
          assert.strictEqual(component.refs.count.props.value, 2);
      });
  
      it('overrides the value property for the ages', function () {
          assert.strictEqual(component.refs.age1.props.value, null);
      });
  });
  </code></pre>
  
  <p>…on the <code>setState</code> line I'm getting:</p>
  
  <p><em>Uncaught Error: Invariant Violation: dangerouslyRenderMarkup(...): Cannot render markup in a worker thread. Make sure <code>window</code> and <code>document</code> are available globally before requiring React when unit testing or use React.renderToString for server rendering.</em></p>
  
  <p>I know that <code>window</code> and <code>document</code> globals are indeed set by the jsdom-based <code>TestBrowser</code>, like that:</p>
  
  <pre><code>global.document = jsdom.jsdom('&lt;html&gt;&lt;body&gt;&lt;/body&gt;&lt;/html&gt;', jsdom.level(1, 'core'));
  global.window = global.document.parentWindow;
  </code></pre>
  
  <p>I even tried to wrap <code>setState</code> into a <code>setTimeout(..., 0)</code>. It doesn't help. How can I make testing the state changes work?</p>