41 lines
5.7 KiB
JavaScript
41 lines
5.7 KiB
JavaScript
|
"use strict";
|
||
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||
|
};
|
||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||
|
const qrcode_terminal_1 = __importDefault(require("qrcode-terminal"));
|
||
|
const chalk_1 = __importDefault(require("chalk"));
|
||
|
const log_1 = __importDefault(require("./log"));
|
||
|
const promisify_event_1 = __importDefault(require("promisify-event"));
|
||
|
const dedent_1 = __importDefault(require("dedent"));
|
||
|
async function default_1(testCafe, remoteCount, showQRCode) {
|
||
|
const connectionPromises = [];
|
||
|
if (remoteCount) {
|
||
|
log_1.default.hideSpinner();
|
||
|
const description = (0, dedent_1.default)(`
|
||
|
Connecting ${remoteCount} remote browser(s)...
|
||
|
Navigate to the following URL from each remote browser.
|
||
|
`);
|
||
|
log_1.default.write(description);
|
||
|
if (showQRCode)
|
||
|
log_1.default.write('You can either enter the URL or scan the QR-code.');
|
||
|
const connectionUrl = testCafe.browserConnectionGateway.connectUrl;
|
||
|
log_1.default.write(`Connect URL: ${chalk_1.default.underline.blue(connectionUrl)}`);
|
||
|
if (showQRCode)
|
||
|
qrcode_terminal_1.default.generate(connectionUrl);
|
||
|
for (let i = 0; i < remoteCount; i++) {
|
||
|
connectionPromises.push(testCafe
|
||
|
.createBrowserConnection()
|
||
|
.then((bc) => (0, promisify_event_1.default)(bc, 'ready').then(() => bc))
|
||
|
.then((bc) => {
|
||
|
log_1.default.write(`${chalk_1.default.green('CONNECTED')} ${bc.userAgent}`);
|
||
|
return bc;
|
||
|
}));
|
||
|
}
|
||
|
log_1.default.showSpinner();
|
||
|
}
|
||
|
return await Promise.all(connectionPromises);
|
||
|
}
|
||
|
exports.default = default_1;
|
||
|
module.exports = exports.default;
|
||
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicmVtb3Rlcy13aXphcmQuanMiLC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