问题描述
我正在使用 Testcafe runner 来执行我得到的一些测试.一切完成后,控制台将永远执行脚本.
I'm using Testcafe runner to execute some tests i got. When everything is finished the console remains executing the script forever.
这是我的代码:
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();
});
控制台保持如下:
测试失败:0
并且从不关闭进程.
推荐答案
我已经重现了这个问题.如果您使用 testcafe-browser-provider-nightmare
运行测试,该过程将挂起.如果您在本地浏览器中运行测试,则该过程会成功完成.我在 TestCafe 存储库中创建了一个问题:https://github.com/DevExpress/testcafe/issues/1493.您可以订阅它以在问题解决时收到通知.作为一种解决方法,您可以在代码中调用 process.exit
:
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);
});
更新:该问题已在 testcafe-browser-provider-nightmare@0.0.5
这篇关于如何关闭 testcafe runner的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!