feat(testing): add serviceWorker tests
This commit is contained in:
15
test/patches/service-worker-mock-fetch.patch
Normal file
15
test/patches/service-worker-mock-fetch.patch
Normal file
@@ -0,0 +1,15 @@
|
||||
--- node_modules/service-worker-mock/fetch.js 2021-02-18 13:47:55.000000000 -0700
|
||||
+++ patches/service-worker-mock-fixed.js 2021-02-18 15:49:47.000000000 -0700
|
||||
@@ -1,8 +1,11 @@
|
||||
module.exports = async (request) => {
|
||||
+ const Response = require('./models/Response');
|
||||
const response = new Response('Response from service-worker-mock/fetch.js', {
|
||||
status: 200,
|
||||
statusText: 'ok.'
|
||||
});
|
||||
- response.url = request.url;
|
||||
+ if (request && request.url) {
|
||||
+ response.url = request.url;
|
||||
+ }
|
||||
return response;
|
||||
};
|
||||
9
test/patches/service-worker-mock-response.patch
Normal file
9
test/patches/service-worker-mock-response.patch
Normal file
@@ -0,0 +1,9 @@
|
||||
--- node_modules/service-worker-mock/models/Response.js 2021-02-18 13:47:55.000000000 -0700
|
||||
+++ patches/service-worker-mock-response.js 2021-02-18 15:57:12.000000000 -0700
|
||||
@@ -1,5 +1,6 @@
|
||||
// stubs https://developer.mozilla.org/en-US/docs/Web/API/Response
|
||||
const Body = require('./Body');
|
||||
+const Blob = require('./Blob');
|
||||
const Headers = require('./Headers');
|
||||
|
||||
const isSupportedBodyType = (body) =>
|
||||
14
test/patches/service-worker-types.patch
Normal file
14
test/patches/service-worker-types.patch
Normal file
@@ -0,0 +1,14 @@
|
||||
--- node_modules/@types/service-worker-mock/index.d.ts 2021-02-18 13:51:50.000000000 -0700
|
||||
+++ patches/service-workertypes.d.ts 2021-02-18 16:30:01.000000000 -0700
|
||||
@@ -3,6 +3,11 @@
|
||||
// Definitions by: Remco Haszing <https://github.com/remcohaszing>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.8
|
||||
+// https://gist.github.com/shqld/32df51a4a4ed429f2c76e4e2cfdf6f96#gistcomment-2793376
|
||||
+// excludes default libs such as 'dom' conflicting with 'webworker'
|
||||
+/// <reference no-default-lib="true"/>
|
||||
+/// <reference lib="esnext" />
|
||||
+/// <reference lib="webworker" />
|
||||
|
||||
export = makeServiceWorkerEnv;
|
||||
declare function makeServiceWorkerEnv(): WorkerGlobalScope;
|
||||
Reference in New Issue
Block a user