Hi guys, quick question. Has anyone had any luck w...
# orm-help
j
Hi guys, quick question. Has anyone had any luck with unit testing using prisma? At the moment we're using MySQL but the problem is we have to have a separate database to run unit tears against. Is there any nice way to mock prisma or perform the database calls on SQLite or in memory? It's just a bit slow running against a full database then wiping it down plus it'll be even slower when we implement CI/CD
q
AFAIK you can use sqlite with Prisma: https://www.prisma.io/docs/concepts/database-connectors/sqlite Then you just need two schema files, one dedicated for testing. You can use npm scripts (like pretest or prebuild) to generate client with proper schema. This is actually a plan of my team for unit testing, as we are migrating to Prisma, so I can't say if it's actually working 😞
j
You used to be able to set up a schema to work with multiple providers then switch between them at runtime, but that feature was removed with the rationale that there were too many gotchas that could cause there to be differences between DB engines and that it would need significantly more work for them to get it to where they'd be comfortable with it (the feeling was that it was premature)
j
Couldn't generating at pre-test or pre-build cause some gotchas when you're working locally? Wouldn't you need a post-build to generate the proper client
q
@John McElreavey yeah, for local development you can
prestart
script
j
Hey that'd work perfectly for starting up the app but if I'm already running the app and decide to run unit tests then I'd have issues. Unless there's some nice way to separate the client generation for the unit tests.