Might have asked this before but any

Might have asked this before, but any chance there will be a way to run a single function/file in a Workers environment, for unit testing, without having to mock an entire Worker just to test it?
4 Replies
MrBBot
MrBBot15mo ago
Hey! 👋 This is kinda what Miniflare's test environments let you do at the moment (https://miniflare.dev/testing/vitest). Are you referring to supporting this in Miniflare 3, or something else?
Hello, I’m Allie!
Ooh, interesting! Is there a way to generate the bindings directly within test too(assuming that bindings may vary across different tested scripts)?
MrBBot
MrBBot15mo ago
Unfortunately not, what types of bindings are you trying to use? For something like a KV namespace, why couldn't you reuse the same namespace across different tests and rely on the isolated storage (https://miniflare.dev/testing/vitest#isolated-storage) mechanism to reset it between tests?
Hello, I’m Allie!
Oh ok, I see that now. Yeah, passing them around would probably be fine! Thanks for pointing that out!