Skip to content

Commit

Permalink
Unregister service workers in Cypress tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ajuvonen committed Mar 26, 2024
1 parent 07d31fd commit 7832c4d
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions cypress/support/e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,15 @@
// Import commands.js using ES2015 syntax:
import './commands';

beforeEach(async () => {
if (!window.navigator || !navigator.serviceWorker) {
return null;
}
const registrations = await navigator.serviceWorker.getRegistrations();
return Promise.all(registrations.map((registration) => {
return registration.unregister();
}));
});

// Alternatively you can use CommonJS syntax:
// require('./commands')

0 comments on commit 7832c4d

Please sign in to comment.