一段时间以来,我一直收到此错误,我决定今天修复它,但是一个小时后尝试修复它,我可以找到解决方案。
当我测试猫鼬用户模型时,会生成此错误/警告:
Mongoose: mpromise (mongoose's default promise library) is deprecated, plug in your own promise library instead: http://mongoosejs.com/docs/promises.html
这是我的测试:
1 var assert = require('chai').assert; 2 var mongoose = require('mongoose'); 3 var clearDB = require('mocha-mongoose')(require('../../config/database').uri, { skip: ['workouts'] }); 4 var database = require('../../config/database').connect; 5 6 var User = require('../../app/models/user'); 7 var user = new User({}); 8 9 var req_body = { 10 username: "garyvee", 11 email: "gary@vaynermedia.com", 12 password: "secret" 13 }; 14 15 describe('User', function() { 16 beforeEach(function(done) { 17 user.username = "johnsmith"; 18 user.email = "john@gmail.com"; 19 user.password = "secret"; 20 done(); 21 }); 22 23 it('can be saved', function() { 24 return user.save(function(err: any) { 25 assert.isNull(err); 26 }) 27 }); 28 });
我认为它与无关,.save但我不知道如何解决。有人可以帮助我,告诉我如何解决它,以便不显示错误/警告。
.save
您需要插入一个Promise库(q,bluebird,es6一个…)
mongoose.Promise = require('bluebird');