I would like to mock the window.open function in testcafe. so that if my app calls window.open rather than hitting actual one we can use mock
something like this would be better
onBeforeLoad: (window) => {
cy.stub(window, 'open');
}
I would like to mock the window.open function in testcafe. so that if my app calls window.open rather than hitting actual one we can use mock
something like this would be better
onBeforeLoad: (window) => {
cy.stub(window, 'open');
}
To achieve this goal, use the 'Inject Scripts into Tested Pages' feature.
const mockWindowOpen = "window.open = function () { };";
test
('My test', async t => { /* ... */ })
.clientScripts({ content: mockWindowOpen });