Cant clear database after tests are run on Mocha and Chai using mongodb with mongoose in my node.js app Cant clear database after tests are run on Mocha and Chai using mongodb with mongoose in my node.js app mongoose mongoose

Cant clear database after tests are run on Mocha and Chai using mongodb with mongoose in my node.js app


I don't think model has any inbuilt drop method. You need to either use db.collection("collectionName").drop() for which you need handle of current db or use deleteMany and delete everything inside the collection. something like this

describe('Task', (done) => {  afterEach(() => {    Task.crud.deleteMany({}, (err, response) => {      done();    });  });});