如题为什么会出现 done()调用两次,
user.save() 返回 Promise , success then, fail catch, 不知道有没人遇到过求告知
done就直接return好了.
http://liubin.github.io/promises-book/#chapter3-promise-testing
Mocha支持 Promise
describe('Model User', function(){ it('add a user', function(done){ var user = new User({ uname: 'cx', password: 'cx' }) user.save() .then(function(){ assert(false) }).then(done,done) }) }) //或者 describe('Model User', function(){ it('add a user', function(){ var user = new User({ uname: 'cx', password: 'cx' }) return user.save() .then(function(){ assert(false) }) }) })
自己写错了
CNode 社区为国内最专业的 Node.js 开源技术社区,致力于 Node.js 的技术研究。
done就直接return好了.
http://liubin.github.io/promises-book/#chapter3-promise-testing
Mocha支持 Promise
自己写错了