Skip to content

Instantly share code, notes, and snippets.

@gauntface
Created March 6, 2017 22:06
Show Gist options
  • Select an option

  • Save gauntface/899ba1f46c3daa0808d9409db9a518ac to your computer and use it in GitHub Desktop.

Select an option

Save gauntface/899ba1f46c3daa0808d9409db9a518ac to your computer and use it in GitHub Desktop.
Example browser test that registers a service worker file that will contain JS Unit Tests
describe('Run SW Unit Tests', function() {
beforeEach(function() {
return window.__testCleanup();
});
after(function() {
return window.__testCleanup();
});
it('should run sw-unit-tests.js unit tests', function() {
return navigator.serviceWorker.register('/test/sw/sw-unit-tests.js')
.then((reg) => {
return window.__waitForSWState(reg, 'activated');
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment