UNPKG

flagpole

Version:

Simple and fast DOM integration, headless or headful browser, and REST API testing framework.

61 lines 3.16 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.SuiteExecutionInline = void 0; const flagpole_execution_1 = require("../flagpole-execution"); const suite_execution_1 = require("./suite-execution"); const flagpole_report_1 = require("../logging/flagpole-report"); const util_1 = require("../util"); const flagpole_1 = require("../flagpole"); class SuiteExecutionInline extends suite_execution_1.SuiteExecution { static executePath(filePath) { const execution = new SuiteExecutionInline(); execution.executePath(filePath); return execution; } static executeSuite(config) { const execution = new SuiteExecutionInline(); execution.executeSuite(config); return execution; } _execute(filePath) { return __awaiter(this, void 0, void 0, function* () { let exitCode = suite_execution_1.SuiteExecutionExitCode.success; const opts = flagpole_execution_1.FlagpoleExecution.global.clone({ automaticallyPrintToConsole: true, }); const globalOpts = flagpole_execution_1.FlagpoleExecution.global.clone(); flagpole_execution_1.FlagpoleExecution.global = opts; const preSuiteCount = flagpole_1.Flagpole.suites.length; yield require(`${filePath}`); const postSuiteCount = flagpole_1.Flagpole.suites.length; if (postSuiteCount > preSuiteCount) { const createdSuites = flagpole_1.Flagpole.suites.slice(preSuiteCount); const promises = []; createdSuites.forEach((suite) => { promises.push(suite.finished); }); yield Promise.all(promises); yield util_1.asyncForEach(createdSuites, (suite) => __awaiter(this, void 0, void 0, function* () { if (suite.hasFailed) { exitCode = suite_execution_1.SuiteExecutionExitCode.failure; } const report = new flagpole_report_1.FlagpoleReport(suite); this._logLine(yield report.toString()); })); } flagpole_execution_1.FlagpoleExecution.global = globalOpts; return new suite_execution_1.SuiteExecutionResult(this._output, exitCode); }); } } exports.SuiteExecutionInline = SuiteExecutionInline; //# sourceMappingURL=suite-execution-inline.js.map