Hey ๐ For now you ll need to define
Hey! ๐ For now, you'll need to define your own
ExecutionContext
class:
A better solution is in the works though. ๐9 Replies
Hi there! Any progress on this? I've gotten pretty stuck trying to instantiate a Miniflare instance inside my Jest test using Module syntax but the only reason I need to is to pass a context to my handleRequest function.
@MrBBot Also, probably worth mentioning here: https://miniflare.dev/testing/jest - took me quite a while to find my way to these discord messages
๐คน Jest Environment ยท Miniflare
Fun, full-featured, fully-local simulator for Cloudflare Workers
Down at the bottom of the page it shows use of new ExecutionContext() but never mentions it's a roll-your-own situation.
Hey!
ExecutionContext
should be provided as a global class as of Miniflare 2.8.0
(https://github.com/cloudflare/miniflare/releases/tag/v2.8.0).@mrbbot Do I need to add it to globals or something? My setup is based on the miniflare-typescript-esbuild-jest repository here: https://github.com/cloudflare/miniflare-typescript-esbuild-jest. Here's what I'm seeing when I try to use the code from the Jest page (https://miniflare.dev/testing/jest) without building it by hand... seems to think it's just a typescript type.
๐คน Jest Environment ยท Miniflare
Fun, full-featured, fully-local simulator for Cloudflare Workers
Using 2.13.0
Hmmm, that's a good point. You could try something like...
...though I suspect that will conflict with the
@cloudflare/workers-types
type.
Let me know if that works, if not, you might just need to use a // @ts-expect-error
comment. ๐ฆ
In any case, this is definitely something we should fix. ๐Unknown Userโข10mo ago
Message Not Public
Sign In & Join Server To View