TypeError: Cannot read property 'drop' of undefined TypeError: Cannot read property 'drop' of undefined mongoose mongoose

TypeError: Cannot read property 'drop' of undefined


I am afraid that you cannot drop collection like that:

db.User.drop()

If you want to drop collection then you should do something like this:mongoose.connection.db.dropCollection('User', function(err, result) {...});


As @drinchev said, you can remove all documents by doing this :

Model.remove({}, function(err) {     console.log('collection removed') });

In your case :

after(()=>{    db.User.remove({}, (err) => {      if (err) throw err;    });})

Hope it helps.