Innovenergy_trunk/frontend/node_modules/testcafe/lib/browser/connection/get-hints.js

35 lines
6.5 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 lodash_1 = require("lodash");
const humanize_duration_1 = __importDefault(require("humanize-duration"));
const error_hints_1 = __importDefault(require("./error-hints"));
const browser_connection_timeouts_1 = require("../../utils/browser-connection-timeouts");
const render_template_1 = __importDefault(require("../../utils/render-template"));
const templates_1 = __importDefault(require("../../errors/runtime/templates"));
// NOTE: hint about too high concurrency factor will be added to the error after exceeding this value
const CONCURRENCY_FACTOR_UPPERBOUND = 3;
function getUsedTimeoutMsg(browserInitTimeout) {
if (browserInitTimeout) {
const browserInitTimeoutStr = (0, humanize_duration_1.default)(browserInitTimeout);
return `${browserInitTimeoutStr} for all browsers`;
}
const localInitTimeoutStr = (0, humanize_duration_1.default)(browser_connection_timeouts_1.LOCAL_BROWSER_INIT_TIMEOUT);
const remoteInitTimeoutStr = (0, humanize_duration_1.default)(browser_connection_timeouts_1.REMOTE_BROWSER_INIT_TIMEOUT);
return `${localInitTimeoutStr} for local browsers and ${remoteInitTimeoutStr} for remote browsers`;
}
function getHints(connections, opts) {
const warningsFromConnections = (0, lodash_1.uniq)((0, lodash_1.flattenDeep)(connections.map(bc => bc.warningLog.messages)));
const warningsFromBootstrapper = opts.warningLog.messages;
const hints = [...warningsFromConnections, ...warningsFromBootstrapper];
if (opts.concurrency > CONCURRENCY_FACTOR_UPPERBOUND)
hints.push((0, render_template_1.default)(templates_1.default[error_hints_1.default.TooHighConcurrencyFactor], opts.concurrency));
hints.push((0, render_template_1.default)(templates_1.default[error_hints_1.default.UseBrowserInitOption], getUsedTimeoutMsg(opts.browserInitTimeout)));
hints.push((0, render_template_1.default)(templates_1.default[error_hints_1.default.RestErrorCauses]));
return hints;
}
exports.default = getHints;
module.exports = exports.default;
//# sourceMappingURL=data:application/json;base64,eyJ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