jest-allure2-reporter
Version:
Idiomatic Jest reporter for Allure Framework
29 lines • 1.21 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.extractSourceCode = void 0;
const logger_1 = require("../../logger");
const utils_1 = require("../../utils");
const extractSourceCode = ({ reporterConfig, }) => {
const config = reporterConfig;
return async function extractSourceCodeHelper(location, includeComments = false) {
if ((0, utils_1.isEmpty)(location)) {
return undefined;
}
const plugins = config.sourceCode ? Object.values(config.sourceCode.plugins) : [];
let result = {};
for (const p of plugins) {
try {
result = (0, utils_1.defaults)(result, await p.extractSourceCode?.(location, includeComments));
}
catch (error) {
logger_1.log.warn(error, `Plugin "${p.name}" failed to extract source code for ${location.fileName}:${location.lineNumber}:${location.columnNumber}`);
}
if (result?.code) {
break;
}
}
return (0, utils_1.isEmpty)(result) ? undefined : result;
};
};
exports.extractSourceCode = extractSourceCode;
//# sourceMappingURL=extractSourceCode.js.map