I mocked window.open in my cypress test as
cy.visit('url', {
onBeforeLoad: (window) => {
cy.stub(window, 'open');
}
});
in my application window.open is called as window.open(url,'_self')
I need to check cypress whether proper URL is opened or not
I need to fetch URL used and check if its match the regular expression or not
const match = newRegExp(`.*`,g)
cy.window().its('open').should('be.calledWithMatch', match);
I'm getting error as
CypressError: Timed out retrying: expected open to have been called with arguments matching /.*/g
The following calls were made:
open("https://google.com", "_self") at open (https://localhost:3000/__cypress/runner/cypress_runner.js:59432:22)