service-worker-mock
Advanced tools
Comparing version 1.8.0 to 1.9.0
@@ -37,3 +37,3 @@ // stubs https://developer.mozilla.org/en-US/docs/Web/API/Request | ||
clone() { | ||
if (this.bodyUsed) throwBodyUsed('json'); | ||
if (this.bodyUsed) throwBodyUsed(); | ||
return new Request(this.url, { | ||
@@ -40,0 +40,0 @@ method: this.method, |
{ | ||
"name": "service-worker-mock", | ||
"version": "1.8.0", | ||
"version": "1.9.0", | ||
"main": "index.js", | ||
@@ -5,0 +5,0 @@ "repository": { |
@@ -40,2 +40,4 @@ Service Worker Mock | ||
Additionally we provide a fetch mock in `service-worker-mock/fetch` to easily get up and running (see Getting Started for example). | ||
## Getting Started | ||
@@ -45,6 +47,13 @@ The service worker mock is best used by applying its result to the global scope, then calling `require('../sw.js')` with the path to your service worker file. The file will use the global mocks for things like adding event listeners. | ||
const makeServiceWorkerEnv = require('service-worker-mock'); | ||
const makeFetchMock = require('service-worker-mock/fetch'); | ||
describe('Service worker', () => { | ||
beforeEach(() => { | ||
Object.assign(global, makeServiceWorkerEnv()); | ||
Object.assign( | ||
global, | ||
makeServiceWorkerEnv(), | ||
makeFetchMock(), | ||
// If you're using sinon ur similar you'd probably use below instead of makeFetchMock | ||
// fetch: sinon.stub().returns(Promise.resolve()) | ||
); | ||
jest.resetModules(); | ||
@@ -51,0 +60,0 @@ }); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
23064
98