Created
March 16, 2020 01:59
-
-
Save jamesfulford/26181c332c25d6464c3524510d18e75e to your computer and use it in GitHub Desktop.
Clear Service Workers, Cypress
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// From https://github.com/cypress-io/cypress/issues/702#issuecomment-435873135 | |
beforeEach(() => { | |
if (window.navigator && navigator.serviceWorker) { | |
navigator.serviceWorker.getRegistrations() | |
.then((registrations) => { | |
registrations.forEach((registration) => { | |
registration.unregister(); | |
}); | |
}); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I think it is necessary, but I think it is necessary to wait until all registrations have unregistered:
Also, on a related topic, FWIW, the section at https://glebbahmutov.com/blog/cypress-tips-and-tricks/#disable-serviceworker mentions how to disable service worker registrations.