The TypeScript template repository for Cloudflare Workers includes a test that mocks a GET request by instantiating the Request
to simulate the input parameters for the handleRequest
function.
After some modifications to the template, I now pass the raw FetchEvent
directly to the handleRequest
method instead of using FetchEvent.request
as the default. As a result, I need to find a way to instantiate FetchEvent
in my test to pass it to handleRequest
, rather than using Request
.
I initially thought about adding node-fetch
as a dev dependency to import FetchEvent
, but it seems that this library doesn't offer an implementation for FetchEvent
.
Is there a method to mock the FetchEvent
without relying on another external dependency (such as within the Cloudflare Workers library itself)?