Tom
06/17/2021, 5:49 AMJest 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();
Rich
06/17/2021, 6:41 AMJest 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