title: Test the content of an <iframe> in a React component with Enzyme
body: <p>I've written a simple React component that renders an <code>&lt;iframe&gt;</code>:</p>
  
  <pre><code>export class Iframe extends React.component {
     render() {
          return &lt;iframe src={ this.props.src } /&gt;;
      }
  }
  </code></pre>
  
  <p>and I trying to test it by checking that the content loaded with <code>src</code> is properly populated within the <code>&lt;iframe&gt;</code>.
  In order to do so I try to access <code>frame.contentWindow</code>, but after mounting it with Enzyme it always returns <code>undefined</code>.</p>
  
  <p>I've tried to mock the <code>&lt;iframe&gt;</code> content with Sinon <a href="http://sinonjs.org/docs/#fakeServer" rel="noreferrer"><code>FakeXMLHttpRequest</code></a>:</p>
  
  <pre><code>server = sinon.fakeServer.create();
  server.respondWith('GET', 'test', [200, { 'Content-Type': 'text/html' }, '&lt;!DOCTYPE html&gt;&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;&lt;body&gt;&lt;div class="myClass"&gt;Amazing Unicorn&lt;/div&gt;&lt;/body&gt;&lt;/html&gt;']);
  container = mount(&lt;Iframe src='test' /&gt;);
  </code></pre>
  
  <p>and with <a href="https://stackoverflow.com/a/10419102/372899"><code>&lt;iframe src='data:text/html' &gt;</code></a>:</p>
  
  <pre><code>const src = 'data:text/html;charset=utf-8,&lt;!DOCTYPE html&gt;&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;&lt;body&gt;&lt;div class="myClass"&gt;Amazing Unicorn&lt;/div&gt;&lt;/body&gt;&lt;/html&gt;';
  container = mount(&lt;Iframe src={ src } /&gt;);
  </code></pre>
  
  <p>but in both cases on the test with Enzyme:</p>
  
  <pre><code>container = mount(&lt;Iframe src='...' /&gt;);
  container.instance().contentWindow // equals 'undefined'
  container.find('iframe').contentWindow // equals 'undefined'
  </code></pre>
  
  <p>The component works and renders as expected on the browser when provided with a valid <code>src</code> attribute. Is there any way to access <code>contentWindow</code> in React tests with Enzyme (or any other test framework)?</p>