-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Closed
Labels
pkg/driverThis is due to an issue in the packages/driver directoryThis is due to an issue in the packages/driver directorystage: ready for workThe issue is reproducible and in scopeThe issue is reproducible and in scopetype: enhancementRequested enhancement of existing featureRequested enhancement of existing feature
Description
Add a new event 'namespace' window:*
where *
is any event you can register on the window
. So a user can do the following:
cy.on('window:hashchange', (e) => {})
This would bind to the window's hashchange
event and be unbound after the test finishes running. It would rebind if the page navigates. Any arbitrary window event can be bound and receives the event as normally binding with window.addEventListener
.
// instead of
cy.window().then((win) => {
const handler = () => {
// handling code
win.removeEventListener('foobar', handler)
}
win.addEventListener('foobar', handler, false)
})
// the user can do this
cy.on('window:foobar', (e) => {
// handling code
})
Metadata
Metadata
Assignees
Labels
pkg/driverThis is due to an issue in the packages/driver directoryThis is due to an issue in the packages/driver directorystage: ready for workThe issue is reproducible and in scopeThe issue is reproducible and in scopetype: enhancementRequested enhancement of existing featureRequested enhancement of existing feature