这段代码使我的mocha测试顺利通过:
before(done => {
mockgoose
.prepareStorage()
.then(() => mongoose.connect('mongodb://example.com/TestingDB'))
.then(done)
})
it('passes', done => done())但是,删除before块中的大括号会导致错误:
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)有人知道为什么吗?如果需要更多的上下文,我可以帮忙。
发布于 2017-04-09 23:58:03
上面写着,您之前没有返回任何内容,您只是使用done来指定任务何时完成。现在您正在返回一个Promise (我假设是mockgoose调用的结果),这是令人困惑的mocha。
https://stackoverflow.com/questions/43313107
复制相似问题