0
此代码让我摩卡测试通过而不会出现错误:摩卡功能之前 - 没有花括号错误的lambda;拉姆达用花括号工作
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)
有谁知道为什么吗?如果需要更多的上下文,我可以承担责任。
Ahhhh,是的。通过使用没有花括号的lambda,我有一个隐含的回报!所以,没有大括号,我回来了一个Promsie。通过提供'done',我还指定了一个回调。我只是摆脱“完成”,并在我的快乐方式。谢谢!我是这个Javascript场景的新手:) – jrahhali