Skip to content

Instantly share code, notes, and snippets.

@dankremniov
Created February 16, 2021 14:45
Show Gist options
  • Save dankremniov/0c3e81cf7190de34fcdc5c8249ec8c95 to your computer and use it in GitHub Desktop.
Save dankremniov/0c3e81cf7190de34fcdc5c8249ec8c95 to your computer and use it in GitHub Desktop.
Access window object within cy.intercept

We can use cy.state('window') to get window object synchronously. The command can also be used to store arbitrary state (example).

E.g. within cy.intercept:

cy.intercept('GET', '/test', (req) => {
    const win = cy.state('window');

    // do something with the window
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment