-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Visit command does not call the onBeforeLoad function #7933
Comments
jennifer-shehane
added
the
stage: needs information
Not enough info to reproduce the issue
label
Jul 10, 2020
You are right, my app uses a service-worker and i think if the app is loaded from cache no onLoadBefore event is firing! My updated spec now looks like this and every thing works like expected: describe('test', () => {
beforeEach(() => {
// remove already running service-worker registrations
if (window.navigator && navigator.serviceWorker) {
navigator.serviceWorker.getRegistrations().then(registrations => {
registrations.forEach(registration => {
registration.unregister();
});
});
}
});
it('onload', function() {
cy.on('window:before:load', e => {
console.log('window:before:load');
});
cy.on('window:load', e => {
console.log('window:load');
});
cy.visit('/', {
onBeforeLoad(win) {
console.log('onBeforeLoad');
// prevent new service-worker registrations
// https://glebbahmutov.com/blog/cypress-tips-and-tricks/#disable-serviceworker
delete win.navigator.__proto__.serviceWorker;
},
onLoad(win) {
console.log('onLoad');
}
});
});
}); |
jennifer-shehane
removed
the
stage: needs information
Not enough info to reproduce the issue
label
Jul 14, 2020
See #702 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Current behavior:
onBeforeLoad does not working!
this example:
Produces this logs:
Desired behavior:
the onLoadBefore callbacks are not called, this logs are missing:
Test code to reproduce
see example above
Versions
Cypress version: 4.5.0
Browser: Chrome 83
OS: Windows 10 Enterprise, Version 1709
The text was updated successfully, but these errors were encountered: