Hi, I'm following this guide on unit testing: <htt...
# orm-help
t
Hi, I'm following this guide on unit testing: https://www.prisma.io/docs/guides/testing/unit-testing#singleton. If I run the example on my machine I get the jest warning:
Jest did not exit one second after the test run has completed.
I also thought that the singleton would kind of "mock" the database, but the user still gets created in the real database. What is wrong here? Edit: The warning doesn't show up if I call
await prisma.$disconnect();
r
Hey Tom! Do you have an example repo we could check out? The message
Jest did not exit one second after the test run has completed.
is because the prisma connection is still alive, when you disconnect (as i see you mentioned) and close the connection, Jest can finish running and exit. The singleton will only mock the client, not your database. If you want to test against a test database you could use a separate connection string which points to a test database. This can be configured either by manually commenting out your current
DATABASE_URL
environment variable in your
.env
file, or alternatively via separate
.env
files. https://www.prisma.io/docs/concepts/more/environment-variables/using-multiple-env-files