省略摩卡回调测试

Mocha callback test omitted

本文关键字:测试 回调 摩卡      更新时间:2023-09-26
describe 'app', ->
    it 'should be called by 2', (done) ->
        f 1, (x) ->  
            console.log 'Hi, callback!'
            (x).should.eql 2
            done()
f = (x, g) -> setTimeout g, 5000, x
上面的测试运行了,

但控制台没有记录,所以省略了回调,测试假通过。

为什么摩卡#done没有等到延迟回调?

摩卡默认测试超时为 2000 毫秒。测试超时。

it块中使用this.timeout(5000);更改测试的超时,或在describe块内使用更改该套件的超时。

在此处此处查看文档。