Open grempe opened 2 years ago
Additionally, it seems that the version of @types/service-worker-mock
being included is out of sync with the service-worker-mock
package. The function signature for makeServiceWorkerEnv()
doesn't seem to match (accepts no args).
Doesn't match:
https://github.com/zackargyle/service-workers/blob/master/packages/service-worker-mock/index.js#L150
The out of date, and mismatched types, are another reason not to use this package, or to perhaps take over maintenance and upgrades.
https://blog.cloudflare.com/miniflare/ has been a good replacement for this mock. For my purposes, it is the only reasonable replacement as it can mock Request
s that accept a ReadableStream
which are pretty darn important in CloudFlare workers for proxying purposes.
https://github.com/nelsonjchen/gtr-proxy/tree/snapshot-miniflare-replacement
I have a WIP project using this at the moment and I haven't had time to extract it. Perhaps a PR can be pondered from this.
https://github.com/cloudflare/worker-typescript-template/pull/58
Oh someone beat me to it by 5 days.
This template depends on
service-worker-mock
:https://github.com/cloudflare/worker-typescript-template/blob/master/package.json#L32
The NPM package for this is found here:
https://www.npmjs.com/package/service-worker-mock
The Github repository link at NPM points here:
https://github.com/pinterest/service-workers
However, Github redirects requests to this repo to a new location:
https://github.com/zackargyle/service-workers
And this repo has had no changes since April 2020 and its README header now says:
This project should replace this abandoned dependency with one that is maintained.