Has anyone solved/created a best practice on how t...
# orm-help
a
Has anyone solved/created a best practice on how to run integration tests in an idempotent and isolated way? I've seen a few articles on simply running integration tests, but these don't scale. In past projects I've worked on (that didn't use prisma) each test suite (in jest this would be under the
describe
) would start up its own isolated database/schema and its own base data to perform the tests, then destroy it after being completed. With the nature of
Prisma
requiring the DB_URL outside of the application context, I haven't found a good way of implementing this model. Is there a different way beyond running test in a synchronous fashion? One of my thoughts (for postgres) was to create databases with a UUID so the connection string would be like
<postgresql://localapp:password@localhost:5432/${UUID}>
which with postgres these can reside all in the same DB server. Then drop them on completion/failure of the test. But I don't see a way of doing that.
p
I have a monorepo with an example app that tackles this issue https://github.com/PierreAndreis/yulp
Be aware that the database is spun up per file. This means that every test on a file will share the same database. This is intentional for me as I prefer this way and can run a bunch of small tests instead of a big one.
💯 1
r
@Adam 👋 I’ve done the same here and it scales quite well.
a
Awesome thanks for the examples, I'll give this a go over the weekend
💯 1