respond-framework
Version:
create as fast you think
22 lines (20 loc) • 825 B
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.relativePathToBranch = exports.default = void 0;
const getBranchFromTestPath = () => {
const {
testPath
} = expect.getState();
const relativePath = testPath.replace(process.cwd(), '');
return relativePathToBranch(relativePath);
};
var _default = exports.default = getBranchFromTestPath;
const relativePathToBranch = path => {
path = '/' + path; // todo: put back to absolute paths for tests[].filename
const parts = path.replace('__tests__/', '').split(/\/modules\//); // eg: ['', 'admin', 'child/dir/some-test.js']
const [top_, ...moduleParts] = parts.map(p => p.split('/')[0]); // eg: ['', 'admin', 'child']
return moduleParts.join('.'); // eg: 'admin.child'
};
exports.relativePathToBranch = relativePathToBranch;