Skip to content

Instantly share code, notes, and snippets.

@crazyones110
Created February 17, 2020 04:02
Show Gist options
  • Save crazyones110/e7914cff02c78da82d13f90c371259e6 to your computer and use it in GitHub Desktop.
Save crazyones110/e7914cff02c78da82d13f90c371259e6 to your computer and use it in GitHub Desktop.
const mongoose = require('mongoose')
// ES6
mongoose.Promise = global.Promise
// Connect to the db before tests run
before(done => {
// Connect to mongodb
mongoose.connect('mongodb://localhost/testaroo', {
useNewUrlParser: true,
useUnifiedTopology: true
})
mongoose.connection
.once('open', () => {
console.log('Connection has been made, now make fireworks')
done()
})
.on('error', error => {
console.log('Connection error:', error)
})
})
// Drop the characters collections before each test
beforeEach(done => {
// Drop the collection
mongoose.connection.collections.mariochars.drop(() => {
done()
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment