Is it possible to make Vitest code available both locally and in production?
I wrote a simple test. Do I always need to convert the
/
part to workers address or is there a way to do it in vitest?4 Replies
For each test run vitest spins up a local instance of the worker and makes the request against that. What’s the reason for wanting to test “production” too?
I am new to creating a serverless. This is because I anticipate that there may be different issues when running on a real cloudflare workers server than in my local environment.
There aren’t loads of differences between Wrangler and actually running on the edge, there are some but in my experience I haven’t needed to test the specific cases of them separately.
If you wanted to, you could write another test that actually calls the https://<yourworker>.workers.dev route which tests against production, that’s more of an end to end test than a unit test but might give you the confidence you’re looking for.
Thanks for the advice!