如何等待Jest执行程序完成?

时间:2018-11-12 19:15:42

标签: node.js jestjs

我进行了以下测试,但似乎无法让Jest等待我的exec调用完成运行:

var exec = require('child_process').exec

test('render', async () => {
    await exec('./render.local.sh', (err, out) => {
        console.log(err, out)
        expect(...some file to be created)
    });
})

我该怎么做才能使玩笑等待exec回调被调用?

2 个答案:

答案 0 :(得分:0)

声明后,您需要致电done()

test('render', async (done) => {
    await exec('./render.local.sh', (err, out) => {
        console.log(err, out);
        expect(...some file to be created);
        done();
    });
})

这将标记测试完成。

答案 1 :(得分:0)

我发现另一种可能适用于with inter as ( select m1.product, m1.quality, m1.source, (select max(m2.quality) from mytable m2 where m2.product = m1.product and m2.source in ('Provider1', 'Provider3') ) max_quality from mytable m1 ) select product, quality, source from inter where source in ('Provider1', 'Prodiver3') or quality > max_quality;

的可能性
async