-
Notifications
You must be signed in to change notification settings - Fork 335
Add first-class support for testing workers #1823
Comments
Have you tried using |
I don't see how this going to solve testing. How you would test accessing to KV store and then resetting data? I can see that you are going to call some cleanups functions after these tests run, but with that in mind you are going to completely go through the roof and relying on network request in tests are not a great idea. |
Thanks so much for submitting this feedback! Local and unit testing is definitely something we are investigating and recognize need to do better. @huv1k Would it matter to you whether the code was actually running locally (e.g. emulation) or actually running on our edge? (e.g. script/resources get sent, in the background, to our edge) |
I would prefer to have it running locally because the network is not always reliable and could fail in CI. I could see there would be a mocking function for each feature. |
I agree fully! There should be a way to develop and run tests locally without the requests being routed to the Cloudfare edge.. Other cloud providers such as Azure have support for local development environments. There should be an official support maintained by Cloudflare @rita3ko :) In the mean time you can look into jdanyow's packages collection: Thanks! |
We now have an officially supported solution with miniflare https://miniflare.dev/ We will integrate this more deeply with wrangler in the future, but this is usable today. |
We now have an officially supported solution for this with miniflare https://miniflare.dev/ We'll be integrating this with wrangler more deeply in the future, but this is usable today. I'm going to close this issue for now, but feel free to drop feedback! |
💡 Feature request
I would like to see first-class support for unit testing CF workers.
Describe the feature
Provide testing framework/integration to tests workers with unit and integration tests. I would like to see support for Jest or another testing feature provided out of the box by Cloudflare, right now this missing even documentation is lacking. This should cover all runtime APIs. I created this issue here because I don't know where these kinds of issues should be reported.
Describe the alternatives
There is
@dollarshaveclub/cloudworker
, which is not maintained anymore. You can create your own setup, but it's a little bit hard to mock all features workers provide because the implementation of workers is not open sourced.The text was updated successfully, but these errors were encountered: