API tests
What's the latest take on API tests? I've read "Testing React Components with Convex" (https://stack.convex.dev/testing-react-components-with-convex), but I'm wondering:
Is there a way to test my mutation and query functions directly? Eg not using the strategies suggested in the article Method 1. replace the internal
useQuery
and useMutation
or Method 2. use dependency injection.
Thanks!2 Replies
Hey @Cilla, we're still working on a proper testing harness for testing functions.
You could set up a simple mock yourself that replaces
ctx.db
with a dummy implementation for example.
Hopefully we'll provide such a mock soon ourselves.Thanks @Michal Srb I'll keep my 👀 open for testing updates!