#NestJS + Prisma - swapping database providers for End to End testing?

6 messages · Page 1 of 1 (latest)

neat yew
#

Currently I Have a mock service that replaces my Prisma service in my E2E tests, however I read that you can override the database url which interested me (https://www.prisma.io/docs/reference/api-reference/prisma-client-reference#datasources), however I wondered if it was possible to swap the provider to a SQLITE driver for my E2E tests? I thought my tests could be more authentic if I could utilise my real service rather than mocking. If I have gotten lost with what E2E tests should be, then let me know too! Cheers

Prisma

API reference documentation for Prisma Client.

#

For example, in my project Prisma usually uses MySql/ Postgres, but for testing E2E i was wondering if i could get prisma to use Sqlite instead

gray fog
#

Personally, I'd just change the env variables to point at a test database that's spun up using docker compose or something like that. It would be possible, depending on how easy it is to get the config object for the ORM.

neat yew
#

That sounds good to me - are E2E tests something you would run as part of your CI/CD pipelines?

gray fog
#

I like to. Have a public docker-compose.test.yml that can be spun up in CI for the test db to be hit

neat yew
#

Never even thought of that - thats epic