Drop database in tests


Hi everyone,

I’m looking a way to drop the database before my unit tests however I only found CLI command prisma reset. Are there any command in prisma client in order to accomplish this?



CLI command prisma delete is faster than prisma reset. Unsure if there is a prisma client alternative.


Hi @BenoitRanque

I’m doing unit tests with node plus mocha and before every test, I would like to reset or drop the database like;

lab.experiment(‘webhook’, () => {

lab.beforeEach(async () => await prisma.dropDatabase());

lab.test(‘should receive message and save as feature’, async () => {



Sorry if i wasn’t clear enough.


Hi @lucasgmartins

In one of my applications, I defined a custom function that clears out the Prisma service manually.

Lets say you have a User type and a Post type in your datamodel. You could write a function like the following:

function dropDatabase() {
  return Promise.all([

Then you can call this function prior to seeding the database or wherever you need it:

lab.beforeEach(async () => {
  console.log(Clearing database...);
  await dropDatabase();

Hope that helps! Happy coding!


Hi @IMax153

Actually, I’m doing this way too. I just wonder that should exist an auxiliary function, would be good.

But thanks very much for your answer!


This topic was automatically closed 45 days after the last reply. New replies are no longer allowed.