Will Fischer
10/15/2020, 2:32 PMserverInstance = await server.listen({ port });
invokes a server implementation that uses a generic PrismaClient
instance from your main app server. Obviously, that means that if you import or define your server or database differently in your project setup, you may experience different symptoms.
My solution is basically to create a server generator function that takes an optional PrismaClient
instance as an argument and use that as the database. Then in the test setup you can pass the newly created PrismaClient
to the server. Without that on the server definition, every test will attempt to refer to the client created in the first test block, even after it’s been torn down.Ryan
10/16/2020, 5:54 AM