问题
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