https://cypress.io logo
The idea of ​​this block of code is to replace the...
# e2e-testing
k
The idea of ​​this block of code is to replace the open method before it is called (it's not entirely clear here) .window is a method(cy object command) that gives the object of the page that is currently active. .then - Enables you to work with the subject yielded from the previous command then((window) here we pass the resulting object (as I understand it, you can somehow shorten the name win , is that right?) (window) => { } here we put a new value in our received window object Next, we use the stub command to avoid the following problems. "If an application calls window.open during Cypress test it might lead to two problems: 1)the new URL might point at a different domain, rendering Cypress "blind" and unable to continue the test 2)the new URL might open in the second tab, invisible to Cypress" When we call cy.stub(win, 'open') it replaces win.open method with a Sinon stub function callsFake function dynamically withdraws url which has been placed into original window.open(url, "_blank") window.location = url - redirects us to a new url