UNPKG

dockest

Version:

Dockest is an integration testing tool aimed at alleviating the process of evaluating unit tests whilst running multi-container Docker applications.

66 lines 3.41 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Dockest = exports.sleepWithLog = exports.sleep = exports.execa = exports.logLevel = void 0; const constants_1 = require("./constants"); const errors_1 = require("./errors"); const logger_1 = require("./logger"); const bootstrap_1 = require("./run/bootstrap"); const debug_mode_1 = require("./run/debug-mode"); const log_writer_1 = require("./run/log-writer"); const run_jest_1 = require("./run/run-jest"); const teardown_1 = require("./run/teardown"); const wait_for_services_1 = require("./run/wait-for-services"); const custom_zod_error_map_1 = require("./utils/custom-zod-error-map"); const get_opts_1 = require("./utils/get-opts"); var constants_2 = require("./constants"); Object.defineProperty(exports, "logLevel", { enumerable: true, get: function () { return constants_2.LOG_LEVEL; } }); var execa_wrapper_1 = require("./utils/execa-wrapper"); Object.defineProperty(exports, "execa", { enumerable: true, get: function () { return execa_wrapper_1.execaWrapper; } }); var sleep_1 = require("./utils/sleep"); Object.defineProperty(exports, "sleep", { enumerable: true, get: function () { return sleep_1.sleep; } }); var sleep_with_log_1 = require("./utils/sleep-with-log"); Object.defineProperty(exports, "sleepWithLog", { enumerable: true, get: function () { return sleep_with_log_1.sleepWithLog; } }); (0, custom_zod_error_map_1.setGlobalCustomZodErrorMap)(); class Dockest { constructor(opts) { this.run = async (dockestServices) => { this.config.perfStart = Date.now(); const logWriter = (0, log_writer_1.createLogWriter)({ mode: this.config.containerLogs.modes, serviceNameFilter: this.config.containerLogs.serviceNameFilter, logPath: this.config.containerLogs.logPath, }); const { composeFile, composeOpts, debug, dumpErrors, exitHandler, hostname, runMode, jestLib, jestOpts, mutables, perfStart, runInBand, skipCheckConnection, } = this.config; await (0, bootstrap_1.bootstrap)({ composeFile, dockestServices, dumpErrors, exitHandler, runMode, mutables, perfStart, }); await (0, wait_for_services_1.waitForServices)({ composeOpts, mutables, hostname, runMode, runInBand, skipCheckConnection, logWriter, }); await (0, debug_mode_1.debugMode)({ debug, mutables }); const { success } = await (0, run_jest_1.runJest)({ jestLib, jestOpts, mutables }); await (0, teardown_1.teardown)({ hostname, runMode, mutables, perfStart, logWriter }); success ? process.exit(0) : process.exit(1); }; this.config = (0, get_opts_1.getOpts)(opts); logger_1.Logger.logLevel = this.config.logLevel; errors_1.BaseError.DockestConfig = this.config; if (this.config.jestLib.getVersion() < constants_1.MINIMUM_JEST_VERSION) { throw new errors_1.ConfigurationError(`Outdated Jest version (${this.config.jestLib.getVersion()}). Upgrade to at least ${constants_1.MINIMUM_JEST_VERSION}`); } } } exports.Dockest = Dockest; //# sourceMappingURL=index.js.map