UNPKG

testplane

Version:

Tests framework based on mocha and wdio

41 lines 1.99 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.getTestDependenciesReader = exports.TestDependenciesReader = void 0; const lodash_1 = require("lodash"); const node_path_1 = __importDefault(require("node:path")); const utils_1 = require("./utils"); class TestDependenciesReader { constructor(selectivityRootPath, compression) { this._selectivityTestsPath = node_path_1.default.join(selectivityRootPath, "tests"); this._compression = compression; } async getFor(test) { const testDeps = await (0, utils_1.readTestDependencies)(this._selectivityTestsPath, test, this._compression); let result = { css: [], js: [], modules: [] }; for (const browserId of Object.keys(testDeps)) { const depTypes = Object.keys(testDeps[browserId]); if (!depTypes.length) { continue; } else if (depTypes.length === 1) { result = (0, utils_1.mergeSourceDependencies)(result, testDeps[browserId][depTypes[0]]); } else { let browserDeps = testDeps[browserId][depTypes[0]]; for (let i = 1; i < depTypes.length; i++) { browserDeps = (0, utils_1.mergeSourceDependencies)(browserDeps, testDeps[browserId][depTypes[i]]); } result = (0, utils_1.mergeSourceDependencies)(result, browserDeps); } } return result; } } exports.TestDependenciesReader = TestDependenciesReader; exports.getTestDependenciesReader = (0, lodash_1.memoize)((selectivityRootPath, compression) => { return new TestDependenciesReader(selectivityRootPath, compression); }, (selectivityRootPath, compression) => `${selectivityRootPath}#${compression}`); //# sourceMappingURL=test-dependencies-reader.js.map