Search code examples
node.jsmongodbmongooseend-to-endchimp.js

Cleaning database after tests feature


I am trying to clean database after each feature however every approach which I tried failed. I tried to remove whole mongo collection, dropDatabase almost everything (I guess)

Including

mongoose.connection.dropDatabase(() => {})

User.remove({ 'local.email': '[email protected]' })

It seems like nothing is happening to the records in database. By the way my database is hosted on mlab.com (its not local database). I am establishing moongose.connection during starting application (node server.js) so there is no need for connecting to db from the hook, I think.

I want to implement this code in provided hook below.

enter image description here


Solution

  • I managed to sort this out using code which is in the provided screenshotenter image description here