cy.on('window:alert',(str)=>{
expect(str).to.equal('Hello , share this practice page and share your knowledge');
});
This was executing the assertion but,
cy.on('window.alert()',(str)=>{
expect(str).to.equal('Hello , share this practice page and share your knowledge');
});
But this was not executing the assertion. I am new to cypress and want to understand why and how these two are different?
Actually, there is no difference between them. The cy.on() method calls core javascript methods. Even if you do not add the () sign to the end of a function, the constructor method of the same method will be called, unless it takes a parameter inside the function.