Innovenergy_trunk/frontend/node_modules/testcafe/lib/live/test-runner.js

174 lines
22 KiB
JavaScript
Raw Normal View History

"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 test_run_controller_1 = __importDefault(require("./test-run-controller"));
const controller_1 = __importDefault(require("./controller"));
const runner_1 = __importDefault(require("../runner"));
const bootstrapper_1 = __importDefault(require("./bootstrapper"));
const parse_file_list_1 = __importDefault(require("../utils/parse-file-list"));
const runtime_1 = require("../errors/runtime");
const types_1 = require("../errors/types");
class LiveModeRunner extends runner_1.default {
constructor({ proxy, browserConnectionGateway, configuration, compilerService }) {
super({ proxy, browserConnectionGateway, configuration, compilerService });
this.stopping = false;
this.runnerTaskPromise = null;
this.stopInfiniteWaiting = lodash_1.noop;
this.rejectInfiniteWaiting = lodash_1.noop;
this.assets = null;
this.testRunController = new test_run_controller_1.default();
this.controller = this._createController();
this.embeddingOptions({
TestRunCtor: this.testRunController.TestRunCtor,
assets: [],
});
this.controller = this._createController();
this.configurationCache = null;
}
runTests(isFirstRun = false) {
let runError = null;
return this._finishPreviousTestRuns()
.then(() => {
return this._validateRunnableConfiguration(isFirstRun);
})
.then(() => {
const expectedTestCount = this.configurationCache.tests.length;
this.testRunController.setExpectedTestCount(expectedTestCount);
})
.then(() => {
this.runnerTaskPromise = super.run(this.opts);
return this.runnerTaskPromise;
})
.catch(err => {
this.setBootstrappingError(null);
runError = err;
})
.then(() => {
this.runnerTaskPromise = null;
this.controller.onTestRunDone(runError);
});
}
_validateRunOptions() {
return super._validateRunOptions()
.catch(err => {
this.rejectInfiniteWaiting(err);
});
}
_createRunnableConfiguration() {
if (this.configurationCache)
return Promise.resolve(this.configurationCache);
return super._createRunnableConfiguration()
.then(configuration => {
this.configurationCache = configuration;
return configuration;
})
.catch(err => {
this.rejectInfiniteWaiting(err);
});
}
setBootstrappingError(err) {
this.bootstrappingError = err;
}
run(options) {
this.configurationCache = null;
if (this._running)
throw new runtime_1.GeneralError(types_1.RUNTIME_ERRORS.cannotRunLiveModeRunnerMultipleTimes);
this._running = this._waitUntilExit()
.then(() => {
return this._dispose();
})
.then(() => {
delete this._running;
});
this.opts = Object.assign({}, this.opts, options);
this._setConfigurationOptions()
.then(() => this._setBootstrapperOptions())
.then(() => (0, parse_file_list_1.default)(this.bootstrapper.sources, process.cwd()))
.then(files => {
return this.controller.init(files);
})
.then(() => this._createRunnableConfiguration())
.then(() => this.runTests(true));
return this._running;
}
suspend() {
if (!this.runnerTaskPromise)
return Promise.resolve();
this.stopping = true;
this.testRunController.stop();
this.runnerTaskPromise.cancel();
return this.testRunController.allTestsCompletePromise
.then(() => {
this.stopping = false;
this.controller.onTestRunDone();
});
}
stop() {
return super.stop()
.then(() => {
return this.controller.exit();
});
}
exit() {
if (this.runnerTaskPromise)
this.runnerTaskPromise.cancel();
return Promise.resolve()
.then(() => this.stopInfiniteWaiting())
.then(() => this._running);
}
async _finishPreviousTestRuns() {
var _a;
if (!((_a = this.configurationCache) === null || _a === void 0 ? void 0 : _a.tests))
return;
this.testRunController.run();
}
_validateRunnableConfiguration(isFirstRun) {
if (isFirstRun) {
if (this.bootstrappingError)
return Promise.reject(this.bootstrappingError);
else if (!this.configurationCache) {
// NOTE: Such errors handled in process.on('unhandledRejection') handler.
return Promise.reject(null);
}
return Promise.resolve();
}
return this.bootstrapper._getTests()
.then(tests => {
this.configurationCache.tests = tests;
return this.bootstrappingError ? Promise.reject(this.bootstrappingError) : Promise.resolve();
});
}
_createTask(tests, browserConnectionGroups, proxy, opts) {
opts.live = true;
return super._createTask(tests, browserConnectionGroups, proxy, opts, this.warningLog);
}
_createBootstrapper(browserConnectionGateway, compilerService, messageBus) {
return new bootstrapper_1.default(this, browserConnectionGateway, compilerService, messageBus);
}
_createController() {
return new controller_1.default(this);
}
_waitUntilExit() {
return new Promise((resolve, reject) => {
this.stopInfiniteWaiting = resolve;
this.rejectInfiniteWaiting = reject;
});
}
_disposeAssets(browserSet, reporters, testedApp) {
this.assets = { browserSet, reporters, testedApp };
return Promise.resolve();
}
_dispose() {
this.controller.dispose();
if (!this.assets)
return Promise.resolve();
const { browserSet, reporters, testedApp } = this.assets;
return super._disposeAssets(browserSet, reporters, testedApp);
}
}
exports.default = LiveModeRunner;
module.exports = exports.default;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGVzdC1ydW5uZXIuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvbGl2ZS90ZXN0LXJ1bm5lci5qcyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7OztBQUFBLG1DQUE4QjtBQUM5QixnRkFBOEQ7QUFDOUQsOERBQThDO0FBQzlDLHVEQUErQjtBQUMvQixrRUFBa0Q7QUFDbEQsK0VBQXFEO0FBQ3JELCtDQUFpRDtBQUNqRCwyQ0FBaUQ7QUFFakQsTUFBTSxjQUFlLFNBQVEsZ0JBQU07SUFDL0IsWUFBYSxFQUFFLEtBQUssRUFBRSx3QkFBd0IsRUFBRSxhQUFhLEVBQUUsZUFBZSxFQUFFO1FBQzVFLEtBQUssQ0FBQyxFQUFFLEtBQUssRUFBRSx3QkFBd0IsRUFBRSxhQUFhLEVBQUUsZUFBZSxFQUFFLENBQUMsQ0FBQztRQUUzRSxJQUFJLENBQUMsUUFBUSxHQUFnQixLQUFLLENBQUM7UUFDbkMsSUFBSSxDQUFDLGlCQUFpQixHQUFPLElBQUksQ0FBQztRQUNsQyxJQUFJLENBQUMsbUJBQW1CLEdBQUssYUFBSSxDQUFDO1FBQ2xDLElBQUksQ0FBQyxxQkFBcUIsR0FBRyxhQUFJLENBQUM7UUFFbEMsSUFBSSxDQUFDLE1BQU0sR0FBRyxJQUFJLENBQUM7UUFFbkIsSUFBSSxDQUFDLGlCQUFpQixHQUFHLElBQUksNkJBQXlCLEVBQUUsQ0FBQztRQUN6RCxJQUF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