UNPKG

testbook

Version:
24 lines 1.32 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.runner = void 0; const server_1 = require("./server"); const path_1 = __importDefault(require("path")); const promise_1 = require("./promise"); const SEARCH_PATH = "./src"; const runComponentTests = (file, component) => promise_1.promiseSequence(component.tests.map((test) => () => server_1.runComponentTest(path_1.default.join(SEARCH_PATH, file), component.exportName, test.id).then(([results]) => results.map(({ result }) => result instanceof Error ? { result: "error", error: server_1.serialiseError(result) } : { result }), (e) => console.error(e)))); const runner = () => server_1.findModuleTests(SEARCH_PATH) .then((moduleComponentTests) => promise_1.promiseSequence(moduleComponentTests.map(({ file, components }) => () => promise_1.promiseSequence(components.map((component) => () => runComponentTests(file, component)))))) .then((results) => { const errors = results.flat(3).filter(({ result }) => result === "error"); if (errors.length) { console.error(errors); process.exit(1); } }); exports.runner = runner; //# sourceMappingURL=runner.js.map