user2849167
user2849167

Reputation: 265

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.

Upvotes: 3

Views: 2331

Answers (1)

Alexander Moskovkin
Alexander Moskovkin

Reputation: 1861

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]

Upvotes: 1

Related Questions