UNPKG

@shipengine/connect

Version:

The official developer tooling for building ShipEngine connect apps

40 lines 1.77 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); const load_and_validate_app_1 = tslib_1.__importStar(require("./load-and-validate-app")); const test_results_1 = require("./test-app/runner/test-results"); const log_helpers_1 = require("./utils/log-helpers"); const log_helpers_2 = require("./utils/log-helpers"); async function testApp(pathToApp) { const [testResults, testResultsReducer] = (0, test_results_1.useTestResults)(); // Set NODE_ENV first because its possible that the shipengine.config // might key off the process.env to set environment variables process.env.NODE_ENV = 'test'; // TODO Clean this up later let app; try { (0, log_helpers_1.logStep)('validating app structure'); app = await (0, load_and_validate_app_1.default)(pathToApp); (0, log_helpers_1.logPass)('app structure is valid'); testResultsReducer('INCREMENT_PASSED'); } catch (error) { if ((0, load_and_validate_app_1.isInvalidAppError)(error)) { const errorsCount = error.errors.length; const errorsWithInflection = errorsCount > 1 ? 'errors' : 'error'; (0, log_helpers_1.logFail)(`App structure is not valid - ${errorsCount} ${errorsWithInflection} found`); error.errors.forEach((errorMessage) => { (0, log_helpers_1.logFail)(errorMessage); }); for (let i = 0; i < errorsCount; i++) { testResultsReducer('INCREMENT_FAILED'); } (0, log_helpers_2.logResults)(testResults); return testResults; } throw error; } return testResults; } exports.default = testApp; //# sourceMappingURL=test-app.js.map