243 lines
46 KiB
JavaScript
243 lines
46 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 debug_1 = __importDefault(require("debug"));
|
|
const pretty_hrtime_1 = __importDefault(require("pretty-hrtime"));
|
|
const compiler_1 = __importDefault(require("../compiler"));
|
|
const connection_1 = __importDefault(require("../browser/connection"));
|
|
const browser_set_1 = __importDefault(require("./browser-set"));
|
|
const runtime_1 = require("../errors/runtime");
|
|
const types_1 = require("../errors/types");
|
|
const tested_app_1 = __importDefault(require("./tested-app"));
|
|
const parse_file_list_1 = __importDefault(require("../utils/parse-file-list"));
|
|
const load_1 = __importDefault(require("../custom-client-scripts/load"));
|
|
const string_1 = require("../utils/string");
|
|
const warning_log_1 = __importDefault(require("../notifications/warning-log"));
|
|
const warning_message_1 = __importDefault(require("../notifications/warning-message"));
|
|
const guard_time_execution_1 = __importDefault(require("../utils/guard-time-execution"));
|
|
const async_filter_1 = __importDefault(require("../utils/async-filter"));
|
|
const wrap_test_function_1 = __importDefault(require("../api/wrap-test-function"));
|
|
const type_assertions_1 = require("../errors/runtime/type-assertions");
|
|
const testcafe_hammerhead_1 = require("testcafe-hammerhead");
|
|
const assert_type_1 = __importDefault(require("../api/request-hooks/assert-type"));
|
|
const user_variables_1 = __importDefault(require("../api/user-variables"));
|
|
const option_names_1 = __importDefault(require("../configuration/option-names"));
|
|
const DEBUG_SCOPE = 'testcafe:bootstrapper';
|
|
function isPromiseError(value) {
|
|
return value.error !== void 0;
|
|
}
|
|
class Bootstrapper {
|
|
constructor({ browserConnectionGateway, compilerService, messageBus, configuration }) {
|
|
this.browserConnectionGateway = browserConnectionGateway;
|
|
this.concurrency = 1;
|
|
this.sources = [];
|
|
this.browsers = [];
|
|
this.reporters = [];
|
|
this.filter = void 0;
|
|
this.appCommand = void 0;
|
|
this.appInitDelay = void 0;
|
|
this.tsConfigPath = void 0;
|
|
this.clientScripts = [];
|
|
this.disableMultipleWindows = false;
|
|
this.proxyless = false;
|
|
this.compilerOptions = void 0;
|
|
this.debugLogger = (0, debug_1.default)(DEBUG_SCOPE);
|
|
this.warningLog = new warning_log_1.default(null, warning_log_1.default.createAddWarningCallback(messageBus));
|
|
this.compilerService = compilerService;
|
|
this.messageBus = messageBus;
|
|
this.configuration = configuration;
|
|
this.TESTS_COMPILATION_UPPERBOUND = 60;
|
|
}
|
|
static _getBrowserName(browser) {
|
|
if (browser instanceof connection_1.default)
|
|
return browser.browserInfo.browserName;
|
|
return browser.browserName;
|
|
}
|
|
static _splitBrowserInfo(browserInfo) {
|
|
const remotes = [];
|
|
const automated = [];
|
|
browserInfo.forEach(browser => {
|
|
if (browser instanceof connection_1.default)
|
|
remotes.push(browser);
|
|
else
|
|
automated.push(browser);
|
|
});
|
|
return { remotes, automated };
|
|
}
|
|
_createAutomatedConnections(browserInfo) {
|
|
if (!browserInfo)
|
|
return [];
|
|
return browserInfo
|
|
.map(browser => (0, lodash_1.times)(this.concurrency, () => new connection_1.default(this.browserConnectionGateway, Object.assign({}, browser), false, this.disableMultipleWindows, this.proxyless, this.messageBus)));
|
|
}
|
|
_getBrowserSetOptions() {
|
|
return {
|
|
concurrency: this.concurrency,
|
|
browserInitTimeout: this.browserInitTimeout,
|
|
warningLog: this.warningLog,
|
|
};
|
|
}
|
|
async _getBrowserConnections(browserInfo) {
|
|
const { automated, remotes } = Bootstrapper._splitBrowserInfo(browserInfo);
|
|
if (remotes && remotes.length % this.concurrency)
|
|
throw new runtime_1.GeneralError(types_1.RUNTIME_ERRORS.cannotDivideRemotesCountByConcurrency);
|
|
let browserConnections = this._createAutomatedConnections(automated);
|
|
remotes.forEach(remoteConnection => {
|
|
remoteConnection.messageBus = this.messageBus;
|
|
});
|
|
browserConnections = browserConnections.concat((0, lodash_1.chunk)(remotes, this.concurrency));
|
|
return browser_set_1.default.from(browserConnections, this._getBrowserSetOptions());
|
|
}
|
|
async _filterTests(tests, predicate) {
|
|
return (0, async_filter_1.default)(tests, test => {
|
|
const testFixture = test.fixture;
|
|
return predicate(test.name, testFixture.name, testFixture.path, test.meta, testFixture.meta);
|
|
});
|
|
}
|
|
async _compileTests({ sourceList, compilerOptions, runnableConfigurationId }) {
|
|
const baseUrl = this.configuration.getOption(option_names_1.default.baseUrl);
|
|
const experimentalEsm = this.configuration.getOption(option_names_1.default.experimentalEsm);
|
|
if (this.compilerService) {
|
|
await this.compilerService.init();
|
|
await this.compilerService.setUserVariables(user_variables_1.default.value);
|
|
return this.compilerService.getTests({ sourceList, compilerOptions, runnableConfigurationId }, baseUrl);
|
|
}
|
|
const compiler = new compiler_1.default(sourceList, compilerOptions, { baseUrl, isCompilerServiceMode: false, experimentalEsm });
|
|
return compiler.getTests();
|
|
}
|
|
_assertGlobalHooks() {
|
|
var _a, _b, _c, _d;
|
|
if (!this.hooks)
|
|
return;
|
|
if ((_a = this.hooks.fixture) === null || _a === void 0 ? void 0 : _a.before)
|
|
(0, type_assertions_1.assertType)(type_assertions_1.is.function, 'globalBefore', 'The fixture.globalBefore hook', this.hooks.fixture.before);
|
|
if ((_b = this.hooks.fixture) === null || _b === void 0 ? void 0 : _b.after)
|
|
(0, type_assertions_1.assertType)(type_assertions_1.is.function, 'globalAfter', 'The fixture.globalAfter hook', this.hooks.fixture.after);
|
|
if ((_c = this.hooks.test) === null || _c === void 0 ? void 0 : _c.before)
|
|
(0, type_assertions_1.assertType)(type_assertions_1.is.function, 'globalBefore', 'The test.globalBefore hook', this.hooks.test.before);
|
|
if ((_d = this.hooks.test) === null || _d === void 0 ? void 0 : _d.after)
|
|
(0, type_assertions_1.assertType)(type_assertions_1.is.function, 'globalAfter', 'The test.globalAfter hook', this.hooks.test.after);
|
|
if (this.hooks.request)
|
|
(0, assert_type_1.default)((0, lodash_1.flattenDeep)((0, lodash_1.castArray)(this.hooks.request)));
|
|
}
|
|
_setGlobalHooksToTests(tests) {
|
|
var _a, _b, _c, _d;
|
|
if (!this.hooks)
|
|
return;
|
|
this._assertGlobalHooks();
|
|
const fixtureBefore = ((_a = this.hooks.fixture) === null || _a === void 0 ? void 0 : _a.before) || null;
|
|
const fixtureAfter = ((_b = this.hooks.fixture) === null || _b === void 0 ? void 0 : _b.after) || null;
|
|
const testBefore = ((_c = this.hooks.test) === null || _c === void 0 ? void 0 : _c.before) ? (0, wrap_test_function_1.default)(this.hooks.test.before) : null;
|
|
const testAfter = ((_d = this.hooks.test) === null || _d === void 0 ? void 0 : _d.after) ? (0, wrap_test_function_1.default)(this.hooks.test.after) : null;
|
|
const request = this.hooks.request || [];
|
|
tests.forEach(item => {
|
|
if (item.fixture) {
|
|
item.fixture.globalBeforeFn = item.fixture.globalBeforeFn || fixtureBefore;
|
|
item.fixture.globalAfterFn = item.fixture.globalAfterFn || fixtureAfter;
|
|
}
|
|
item.globalBeforeFn = testBefore;
|
|
item.globalAfterFn = testAfter;
|
|
item.requestHooks = (0, lodash_1.union)((0, lodash_1.flattenDeep)((0, lodash_1.castArray)(request)), item.requestHooks);
|
|
});
|
|
}
|
|
async _getTests(id) {
|
|
const cwd = process.cwd();
|
|
const sourceList = await (0, parse_file_list_1.default)(this.sources, cwd);
|
|
if (!sourceList.length)
|
|
throw new runtime_1.GeneralError(types_1.RUNTIME_ERRORS.testFilesNotFound, cwd, (0, string_1.getConcatenatedValuesString)(this.sources, '\n', ''));
|
|
let tests = await (0, guard_time_execution_1.default)(async () => await this._compileTests({ sourceList, compilerOptions: this.compilerOptions, runnableConfigurationId: id }), elapsedTime => {
|
|
this.debugLogger(`tests compilation took ${(0, pretty_hrtime_1.default)(elapsedTime)}`);
|
|
const [elapsedSeconds] = elapsedTime;
|
|
if (elapsedSeconds > this.TESTS_COMPILATION_UPPERBOUND)
|
|
this.warningLog.addWarning(warning_message_1.default.testsCompilationTakesTooLong, (0, pretty_hrtime_1.default)(elapsedTime));
|
|
});
|
|
const testsWithOnlyFlag = tests.filter(test => test.only);
|
|
if (testsWithOnlyFlag.length)
|
|
tests = testsWithOnlyFlag;
|
|
if (!tests.length)
|
|
throw new runtime_1.GeneralError(types_1.RUNTIME_ERRORS.noTestsToRun);
|
|
if (this.filter)
|
|
tests = await this._filterTests(tests, this.filter);
|
|
if (!tests.length)
|
|
throw new runtime_1.GeneralError(types_1.RUNTIME_ERRORS.noTestsToRunDueFiltering);
|
|
this._setGlobalHooksToTests(tests);
|
|
return tests;
|
|
}
|
|
async _startTestedApp() {
|
|
if (!this.appCommand)
|
|
return void 0;
|
|
const testedApp = new tested_app_1.default();
|
|
await testedApp.start(this.appCommand, this.appInitDelay);
|
|
return testedApp;
|
|
}
|
|
async _canUseParallelBootstrapping(browserInfo) {
|
|
const isLocalPromises = browserInfo.map(browser => browser.provider.isLocalBrowser(void 0, Bootstrapper._getBrowserName(browser)));
|
|
const isLocalBrowsers = await Promise.all(isLocalPromises);
|
|
return isLocalBrowsers.every(result => result);
|
|
}
|
|
async _bootstrapSequence(browserInfo, id) {
|
|
const tests = await this._getTests(id);
|
|
const testedApp = await this._startTestedApp();
|
|
const browserSet = await this._getBrowserConnections(browserInfo);
|
|
return { tests, testedApp, browserSet };
|
|
}
|
|
_wrapBootstrappingPromise(promise) {
|
|
return promise
|
|
.then(result => ({ error: void 0, result }))
|
|
.catch(error => ({ result: void 0, error }));
|
|
}
|
|
async _getBootstrappingError(browserSetStatus, testsStatus, testedAppStatus) {
|
|
if (!isPromiseError(browserSetStatus))
|
|
await browserSetStatus.result.dispose();
|
|
if (!isPromiseError(browserSetStatus) && !isPromiseError(testedAppStatus) && testedAppStatus.result)
|
|
await testedAppStatus.result.kill();
|
|
if (isPromiseError(testsStatus))
|
|
return testsStatus.error;
|
|
if (isPromiseError(testedAppStatus))
|
|
return testedAppStatus.error;
|
|
if (isPromiseError(browserSetStatus))
|
|
return browserSetStatus.error;
|
|
return new Error('Unexpected call');
|
|
}
|
|
_getBootstrappingPromises(arg) {
|
|
const result = {};
|
|
for (const k in arg)
|
|
result[k] = this._wrapBootstrappingPromise(arg[k]);
|
|
return result;
|
|
}
|
|
async _bootstrapParallel(browserInfo, id) {
|
|
const bootstrappingPromises = {
|
|
browserSet: this._getBrowserConnections(browserInfo),
|
|
tests: this._getTests(id),
|
|
app: this._startTestedApp(),
|
|
};
|
|
const bootstrappingResultPromises = this._getBootstrappingPromises(bootstrappingPromises);
|
|
const bootstrappingResults = await Promise.all([
|
|
bootstrappingResultPromises.browserSet,
|
|
bootstrappingResultPromises.tests,
|
|
bootstrappingResultPromises.app,
|
|
]);
|
|
const [browserSetResults, testResults, appResults] = bootstrappingResults;
|
|
if (isPromiseError(browserSetResults) || isPromiseError(testResults) || isPromiseError(appResults))
|
|
throw await this._getBootstrappingError(...bootstrappingResults);
|
|
return {
|
|
browserSet: browserSetResults.result,
|
|
tests: testResults.result,
|
|
testedApp: appResults.result,
|
|
};
|
|
}
|
|
// API
|
|
async createRunnableConfiguration() {
|
|
const id = (0, testcafe_hammerhead_1.generateUniqueId)();
|
|
const commonClientScripts = await (0, load_1.default)(this.clientScripts);
|
|
if (await this._canUseParallelBootstrapping(this.browsers))
|
|
return Object.assign(Object.assign({}, await this._bootstrapParallel(this.browsers, id)), { commonClientScripts, id });
|
|
return Object.assign(Object.assign({}, await this._bootstrapSequence(this.browsers, id)), { commonClientScripts, id });
|
|
}
|
|
}
|
|
exports.default = Bootstrapper;
|
|
module.exports = exports.default;
|
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYm9vdHN0cmFwcGVyLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3J1bm5lci9ib290c3RyYXBwZXIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7QUFBQSxtQ0FNZ0I7QUFFaEIsa0RBQTBCO0FBQzFCLGtFQUF1QztBQUN2QywyREFBbUM7QUFDbkMsdUVBQXVFO0FBQ3ZFLGdFQUF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ZT86IENvbXBpbGVyU2VydmljZTtcbiAgICBwcml2YXRlIHJlYWRvbmx5IGRlYnVnTG9nZ2VyOiBkZWJ1Zy5EZWJ1Z2dlcjtcbiAgICBwcml2YXRlIHJlYWRvbmx5IHdhcm5pbmdMb2c6IFdhcm5pbmdMb2c7XG4gICAgcHJpdmF0ZSByZWFkb25seSBtZXNzYWdlQnVzOiBNZXNzYWdlQnVzO1xuXG4gICAgcHJpdmF0ZSByZWFkb25seSBURVNUU19DT01QSUxBVElPTl9VUFBFUkJPVU5EOiBudW1iZXI7XG5cbiAgICBwdWJsaWMgY29uc3RydWN0b3IgKHsgYnJvd3NlckNvbm5lY3Rpb25HYXRld2F5LCBjb21waWxlclNlcnZpY2UsIG1lc3NhZ2VCdXMsIGNvbmZpZ3VyYXRpb24gfTogQm9vdHN0cmFwcGVySW5pdCkge1xuICAgICAgICB0aGlzLmJyb3dzZXJDb25uZWN0aW9uR2F0ZXdheSA9IGJyb3dzZXJDb25uZWN0aW9uR2F0ZXdheTtcbiAgICAgICAgdGhpcy5jb25jdXJyZW5jeSAgICAgICAgICAgICAgPSAxO1xuICAgICAgICB0aGlzLnNvdXJjZXMgICAgICAgICAgICAgICAgICA9IFtdO1xuICAgICAgICB0aGlzLmJyb3dzZXJzICAgICAgICAgICAgICAgICA9IFtdO1xuICAgICAgICB0aGlzLnJlcG9ydGVycyAgICAgICAgICAgICAgICA9IFtdO1xuICAgICAgICB0aGlzLmZpbHRlciAgICAgICAgICAgICAgICAgICA9IHZvaWQgMDtcbiAgICAgICAgdGhpcy5hcHBDb21tYW5kICAgICAgICAgICAgICAgPSB2b2lkIDA7XG4gICAgICAgIHRoaXMuYXBwSW5pdERlbGF5ICAgICAgICAgICAgID0gdm9pZCAwO1xuICAgICAgICB0aGlzLnRzQ29uZmlnUGF0aCAgICAgICAgICAgICA9IHZvaWQgMDtcbiAgICAgICAgdGhpcy5jbGllbnRTY3JpcHRzICAgICAgICAgICAgPSBbXTtcbiAgICAgICAgdGhp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