To drop a collection:
mongoose.connection.collections.mariochars.drop()
note that we're writing mariochars
(pluralized) and not mariochar
but we've declared the collection as mariochar
. This is the way mongodb works.
To drop the collection before every test so that the result of one test do not affect the other test by using beforeEach
const mongoose = require('mongoose');mongoose.Promise = global.Promise
before(function(done){
// Connect to mongodb
...
})
beforeEach(function(done){
mongoose.connection.collections.mariochars.drop()
done()
})
Top comments (0)