This code makes my mocha tests pass without error:
before(done => {
mockgoose
.prepareStorage()
.then(() => mongoose.connect('mongodb://example.com/TestingDB'))
.then(done)
})
it('passes', done => done())
But removing the curly braces in the before
block causes the error:
before(done =>
mockgoose
.prepareStorage()
.then(() => mongoose.connect('mongodb://example.com/TestingDB'))
.then(done)
)
it('passes', done => done())
1) "before all" hook
0 passing (2s)
1 failing
1) "before all" hook:
Error: Resolution method is overspecified. Specify a callback *or* return a Promise; not both.
at process._tickCallback (internal/process/next_tick.js:109:7)
Does anyone know why? If more context is needed, I can oblige.
答案 0 :(得分:3)
It says so right there, you weren't returning anything before, you were just using done
to specify when the task is done. Now you are returning a Promise
(the result of the mockgoose call i'd assume) and it's confusing mocha.