From aff6596e71b6818fb6c55708f35ea308edbdedcc Mon Sep 17 00:00:00 2001 From: Valeri Karpov Date: Sun, 2 Sep 2018 10:03:15 -0400 Subject: [PATCH] test(mongoose): repro #6890 --- test/index.test.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/test/index.test.js b/test/index.test.js index 8a7e12e39a7..9a742138edb 100644 --- a/test/index.test.js +++ b/test/index.test.js @@ -155,18 +155,18 @@ describe('mongoose module:', function() { it('useCreateIndex option (gh-6880)', function() { const mongoose = new Mongoose(); + const M = mongoose.model('Test', new Schema({ + name: { type: String, index: true } + })); + + M.collection.ensureIndex = function() { + throw new Error('Fail'); + }; + mongoose.set('useCreateIndex', true); return mongoose.connect(uri, options). then(() => { - const M = mongoose.model('Test', new Schema({ - name: { type: String, index: true } - })); - - M.collection.ensureIndex = function() { - throw new Error('Fail'); - }; - return M.init(); }). then(() => {