Open utterances-bot opened 1 year ago
Great post! This got me thinking about how I personally have been testing my Convex apps. I'm curious what you come up with too - probably worth a post on Stack with tips and tricks if you have any already. One thing I'm playing with tonight, for functions where you can avoid DB writes:
npx convex run --watch testing:testMyFunction
convex run
results.Promise.all
. Your CI script then just looks like a npx convex run
command, which includes the build, bundle, deploy, and test steps in one!
It's not perfect, but it's a start. One obvious gap here is having a ready-made database mock to pass into top-level functions to do dependency-injection-style unit testing. If anyone reading this makes one, let me know!
Interesting idea @ianmacartney thanks for sharing! I wonder if there is a way to then have it automatically cache the test so you no longer have to run it unless that specific function changes 🤔
Ultimately I would love to see a mock DB of some sort so we can just write some fast unit tests then sprinkle a few end-to-end and integration tests in there for good measure.
So I made the leap to Postrgres which had the best of both, relational tables AND JSON columns.
I've been saying this ever since I started working on a real work project and never looked back. Now I'm using DynamoDB for the first time.
The fun part of convex queries is the results are trivially cache-able. I could even imagine a meta-query that runs all the query tests, and is constantly subscribed. So long as the subscription is active, it'll re-run on any new code that the queries depend on automatically. It'd require having a long-running CI that's holding the queries open though. And I think mutations are the more interesting things to test generally, but definitely a fun thought experiment
Tinkering With Convex - mikecann.co.uk
BattleTabs
https://mikecann.co.uk/posts/tinkering-with-convex