摩卡单元测试抛出超时超过3000毫秒

时间:2020-05-04 12:52:47

标签: node.js unit-testing express mocha

我想在两次测试之间添加一个延迟,因为其中一个依赖于另一个

一切都很好,除了当我更改参数以测试捕获时,它仅显示此错误

Error: Timeout of 3000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves.

测试代码

it('save Prods', function(done){

        this.timeout(3000); 

        setTimeout(() => {
           graphql.saveProd.resolve(null,
                {
                    prod_id : prod_id,
                })
                .then(data => {

                        expect(data).to.be.an('array')
                        done()

                }).catch(done) <----- as you see here i added done() in both cases (then & catch)

            },3000)
    })

0 个答案:

没有答案