Cory Chambers
Cory Chambers

Reputation: 25

How to run TestCafe on another server

I'm following the TestCafe docs and I get how to write a test and run it locally from the command line. What I'm wondering is how I could host the tests on a remote server and execute them from somewhere else. So far the only way I can see to do it is by setting up the remote server with API that then executes a command to run the TestCafe tests. Is there a simpler way to accomplish this where it can just run the tests with out executing a command?

Upvotes: 0

Views: 567

Answers (1)

aleks-pro
aleks-pro

Reputation: 1669

You can create a TestCafe instance in the NodeJS script and use TestCafe API to run your tests:

const createTestCafe = require('testcafe');
let testcafe         = null;

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

        return runner
            .src('test.js')
            .browsers('chrome')
            .run();
    })
    .then(failedCount => {
        console.log('Tests failed: ' + failedCount);
        testcafe.close();
    });

Please refer to the following topics to find more info about this approach: Runner Object, TestCafe Object

Upvotes: 3

Related Questions