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
25 lines (21 loc) • 882 B
JavaScript
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.detectTestFiles = detectTestFiles;
/**
* detect test files in components
*/
function detectTestFiles(components) {
return components.map(component => {
const paths = component.filesystem.readdirSync('/').filter(path => {
var _component$config$ext;
const testerConfig = (_component$config$ext = component.config.extensions.findExtension('@teambit/tester')) === null || _component$config$ext === void 0 ? void 0 : _component$config$ext.data; // should be used as a default value.
return path.match((testerConfig === null || testerConfig === void 0 ? void 0 : testerConfig.testRegex) || '(/__tests__/.*|(\\.|/)(test|spec))\\.[jt]sx?$');
});
const componentWithSpecs = Object.assign(component, {
specs: paths
});
return componentWithSpecs;
});
}
;