denoland / deploy_feedback

For reporting issues with Deno Deploy
https://deno.com/deploy
74 stars 5 forks source link

Unit Testing In Deploy #451

Closed anywhichway closed 1 year ago

anywhichway commented 1 year ago

What problem are you trying to solve?

There are situations in which unit testing within a deployed project could be useful, e.g. when the Deploy environment behavior can be different than the development environment behavior (as with Deno KV an consistency).

Describe the solution you'd like

A means to import test files, e.g. index.test.js, and run them with results going to the sever logs.

Describe alternatives you've considered

I have actually implemented a quick solution in about 60 lines of code. It redefines Deno.test and processes the unit test file in the context of the redefinition. See https://dash.deno.com/playground/strong-robin-14. With the source of https://www.unpkg.com/denobase@0.0.20/index.test.js being the most germain part. This file can be processes locally using the standard Deno test command line or used in a deplotyed environment.

Documentation, Adoption, Migration Strategy

I seems it would be relatively straight forward to abstract out the parts of https://dash.deno.com/playground/strong-robin-14 and https://www.unpkg.com/denobase@0.0.20/index.test.js so that they could be generically applied.

If the Deno team thinks this would be worthwhile but not a priority for the core of Deno, I am happy to do the work and publish as a package to deno.land.

anywhichway commented 1 year ago

Closing this because I just discovered the exposure of the test framework. Not well documented at https://deno.land/manual@v1.35.3/introduction. Although I have not yet tried to use in Deno Deploy, my guess is it will work better or as well as the approach I hacked up.