Recipe and tips to create custom service bindings (with vitest integration) #6780
benjavicente
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Related to my closed issue #6757 about "reading files" inside vitest using R2.
And maybe to the question service bindings: How does one mock a service binding?
In tests, it might be useful to use an API that are non-compatible with the worked runtime. For example, reading files (with
node:fs
) containing plain emails or requests, which can be used to test worker handlers. I found that this can be archived with aserviveBinding
(link to docs, and the Wrapped Bindings Example):Are there guides or tips to this type of configuration/tricks? I could not find documentation or discussions about something like this (custom or mock of service bindings).
For example:
My use case is testing the email handler, creating a binding with a path-to-eml-file→EmailMessage interface 🤔
Beta Was this translation helpful? Give feedback.
All reactions