Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to close testcafe runner

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.

like image 449
user2849167 Avatar asked Jul 24 '26 10:07

user2849167


1 Answers

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 [email protected]

like image 167
Alexander Moskovkin Avatar answered Jul 28 '26 08:07

Alexander Moskovkin