Replies: 1 comment 3 replies
-
There's nothing like "Isolated tests" when doing db tests. The reason: You need to have a db with the current schema and mock data. Either you create aforementioned for every unit text, or every unit test group or not. The best way is:
In general, you should be cautious with doing too many unit tests. Many unit tests (something dynamic langs like RoR do a lot) are not really required if you have end-to-end type safety which you have with TypeScript and Drizzle; this is the main reason we are using TypseScript and Drizzle, otherwise why are you using them? Also doing too many unit tests slows down development (in particalur when refactoring) and are not DRY (because you just double the static typing already in place by TS and SQL). Rather focus on the right and few integration tests (reflecting crucial processes, e.g. sign-up, purchase) because your "isolated tests" are defacto integration tesst if you consider the preconditions you need to have. Bonus: Always test against the dev instance of your production database; so, if your have MySQL as production db, you can't use sqlite for testing; both are entirely different dbs only sharing a similar API layer ("SQL") which is too different, even when used via Drizzle. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm overall wondering what the best strategy to run isolated unit tests using Drizzle is. My original thinking was to use in-memory SQLite databases instead of a shared MySQL since Drizzle seems to support both SQLite and MySQL.
But the main issue I'm facing is that Drizzle supports both by basically acting as different libraries. In short, Drizzle is not a single ORM library to work with these databases, it's a collection of independent libraries that have a somehow similar API. But "somehow similar API" doesn't work well with Typescript.
How are people writing tests for their logic? (Tests that can be isolated, not complete integration tests).
Is the goal of Drizzle to converge toward a single API or is Drizzle not going to be designed for this?
Beta Was this translation helpful? Give feedback.
All reactions