testplane
Version:
Tests framework based on mocha and wdio
67 lines • 2.47 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.BaseTestplane = void 0;
const lodash_1 = __importDefault(require("lodash"));
const plugins_loader_1 = __importDefault(require("plugins-loader"));
const config_1 = require("./config");
const events_1 = require("./events");
const errors_1 = __importDefault(require("./errors"));
const typescript_1 = require("./utils/typescript");
const repl_module_hooks_1 = require("./utils/repl-module-hooks");
class BaseTestplane extends events_1.AsyncEmitter {
static async create(config) {
const instance = new this(config);
await instance._setup();
return instance;
}
constructor(config) {
super();
this._interceptors = [];
this._initEventEmited = false;
this._interceptors = [];
this._pendingConfig = config;
}
async _setup() {
(0, repl_module_hooks_1.registerReplModuleHooks)();
(0, typescript_1.registerTransformHook)(this.isWorker());
this._config = await config_1.Config.create(this._pendingConfig);
this._pendingConfig = undefined;
(0, typescript_1.updateTransformHook)(this._config);
this._setLogLevel();
this._loadPlugins();
}
/** @note Only the first call returns a promise to wait for INIT handlers to complete, subsequent calls return immediately to avoid deadlocks */
async _emitInitEventOnce() {
if (this._initEventEmited) {
return;
}
this._initEventEmited = true;
await this.emitAndWait(events_1.MasterEvents.INIT);
}
get config() {
return this._config;
}
get events() {
return lodash_1.default.extend({}, events_1.MasterEvents, events_1.WorkerEvents);
}
get errors() {
return errors_1.default;
}
intercept(event, handler) {
this._interceptors.push({ event, handler });
return this;
}
_setLogLevel() {
if (!process.env.WDIO_LOG_LEVEL) {
process.env.WDIO_LOG_LEVEL = lodash_1.default.get(this.config, "system.debug", false) ? "trace" : "error";
}
}
_loadPlugins() {
plugins_loader_1.default.load(this, this.config.plugins, "hermione-");
}
}
exports.BaseTestplane = BaseTestplane;
//# sourceMappingURL=base-testplane.js.map