title: Difficulty accessing window object in Cypress
body: <p>I'm trying to access the window object of my App in Cypress in the following manner.</p>
  
  <pre><code>cy.url().should('include', '/home').then(async () =&gt; {
      const window = await cy.window();
      console.log(window);
  });
  </code></pre>
  
  <p>The above method is not working for me as <code>window</code> is returned as <code>undefined</code>.</p>
  
  <p>However, the answer in <a href="https://stackoverflow.com/questions/51122236/cypress-unable-to-access-app-from-window-object">this SO post</a> states the following:</p>
  
  <blockquote>
    <p>Or you can use cy.state('window') which returns the window object
    synchronously, but this is undocumented and may change in the future.</p>
  </blockquote>
  
  <p>This method <strong>does</strong> return the window value successfully.</p>
  
  <pre><code>cy.url().should('include', '/home').then(async () =&gt; {
      const window = cy.state('window');
      console.log(window);
  });
  </code></pre>
  
  <p><strong>As the answer suggests, cy.state('window') is undocumented so I would still rather use cy.window(). Is there any reason why it's returning undefined? (I started learning cypress today.)</strong></p>