'use strict';

const createTestCafe = require('testcafe');
const selfSignedSertificate = require('openssl-self-signed-certificate');
let runner = null;

const sslOptions = {
    key: selfSignedSertificate.key,
    cert: selfSignedSertificate.cert
};

createTestCafe('192.168.0.51', 5000, 5001, sslOptions).then(async testcafe => {
    runner = testcafe.createRunner();

    let remoteConnection = await testcafe.createBrowserConnection();
    console.log(remoteConnection.url);

    remoteConnection.once('ready', () => {
        console.log("testing...");
        return runner.src('test/test.testcafe.js').browsers(remoteConnection).run({debugOnFail: true}).then(failedCount => {
            testcafe.close();
        });
    });
});

