How to close testcafe runner

佐手、 提交于 2019-12-10 19:34:05

问题


I'm using Testcafe runner to execute some tests i got. When everything is finished the console remains executing the script forever.

Here is my code:

createTestCafe('localhost', 1337, 1338)
.then(tc => {
    testcafe     = tc;
    runner = testcafe.createRunner();

    return runner
        .src(['offerRefresh.js'])
        .browsers(['nightmare'])
        .screenshots('./screenshots', true)
        .run();
})
.then(failedCount => {
    console.log('Tests failed: ' + failedCount);
    testcafe.close();
});

The console remains like this:

Tests failed: 0

And never closes the process.


回答1:


I've reproduced the problem. The process hangs if you run tests with testcafe-browser-provider-nightmare. If you run tests in a local browser, the process finishes successfully. I've created an issue in the TestCafe repository: https://github.com/DevExpress/testcafe/issues/1493. You can subscribe to it to be notified when the problem is fixed.   As a workaround, you can call process.exit in your code:

...
    .then(failedCount => {
    console.log('Tests failed: ' + failedCount);
    testcafe.close();
    process.exit(failedCount ? 1 : 0);
});

UPDATED: the issue is fixed in testcafe-browser-provider-nightmare@0.0.5



来源:https://stackoverflow.com/questions/44132703/how-to-close-testcafe-runner

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!