How to test Server Functions #2701
cameronb23
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I believe that server functions, just like any other functions or unit of work, should be able to be well tested. Currently, this doesn't work out of the box as expected (via Vitest) due to some inherent checks that are made and errors thrown when creating the server function:
While this is likely necessary for Start, there should be some official method or guidance on how to test these functions. I could imagine there being a change made to
createServerFn
to ignore these checks if the environment is test or something, or this may be as simple as adding a section to the documentation. For now, the best that I have come up with is mocking the call globally - this is an example for Vitest, but I assume it would be similar for Jest and others.Beta Was this translation helpful? Give feedback.
All reactions