Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

service-worker-mock

Package Overview
Dependencies
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

service-worker-mock - npm Package Compare versions

Comparing version 1.8.0 to 1.9.0

2

models/Request.js

@@ -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 @@ });

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc