UNPKG

bit-bin

Version:

<a href="https://opensource.org/licenses/Apache-2.0"><img alt="apache" src="https://img.shields.io/badge/License-Apache%202.0-blue.svg"></a> <a href="https://github.com/teambit/bit/blob/master/CONTRIBUTING.md"><img alt="prs" src="https://img.shields.io/b

85 lines (66 loc) 1.78 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.TesterTask = void 0; function _bluebird() { const data = require("bluebird"); _bluebird = function () { return data; }; return data; } function _path() { const data = require("path"); _path = function () { return data; }; return data; } function _constants() { const data = require("../../constants"); _constants = function () { return data; }; return data; } function _utils() { const data = require("./utils"); _utils = function () { return data; }; return data; } // move else where!!! const CAPSULES_BASE_DIR = (0, _path().join)(_constants().CACHE_ROOT, 'capsules'); /** * tester build task. Allows to test components during component build. */ class TesterTask { constructor(extensionId) { this.extensionId = extensionId; } execute(context) { return (0, _bluebird().coroutine)(function* () { const tester = context.env.getTester(); const components = (0, _utils().detectTestFiles)(context.components); const testMatch = components.reduce((acc, component) => { const specs = component.specs.map(specFile => { const capsule = context.capsuleGraph.capsules.getCapsule(component.id); if (!capsule) throw new Error('capsule not found'); return (0, _path().join)(capsule.wrkDir, specFile); }); acc = acc.concat(specs); return acc; }, []); const testerContext = Object.assign(context, { release: true, specFiles: testMatch, rootPath: CAPSULES_BASE_DIR }); // @todo: Ran to fix. // @ts-ignore return tester.test(testerContext); })(); } } exports.TesterTask = TesterTask;