Created
November 18, 2019 23:14
-
-
Save jpedroschmitz/5f146604535176eec17fa5447e9e47d8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let mongoServer; | |
beforeAll(async () => { | |
mongoServer = new MongoMemoryServer(); | |
const URI = await mongoServer.getUri(); | |
mongoose.connect(URI, { | |
useNewUrlParser: true, | |
useCreateIndex: true, | |
useUnifiedTopology: true, | |
}); | |
}); | |
afterAll(async done => { | |
mongoose.disconnect(done); | |
await mongoServer.stop(); | |
}); | |
afterEach(async () => { | |
const collections = await mongoose.connection.db.collections(); | |
for (let collection of collections) { | |
await collection.deleteMany(); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment