UNPKG

jest-allure2-reporter

Version:
59 lines 2.57 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.AllureRuntimeContext = void 0; const tslib_1 = require("tslib"); const handlebars_1 = tslib_1.__importDefault(require("handlebars")); const utils_1 = require("../utils"); const metadata_1 = require("../metadata"); const logger_1 = require("../logger"); const attachmentHandlers = tslib_1.__importStar(require("./attachment-handlers")); class AllureRuntimeContext { contentAttachmentHandlers; fileAttachmentHandlers; handlebars = handlebars_1.default.create(); inferMimeType; getReporterConfig; getFileMetadata; getGlobalMetadata; getCurrentMetadata; getNow; flush; enqueueTask; constructor(config) { this.contentAttachmentHandlers = config.contentAttachmentHandlers ?? { write: attachmentHandlers.writeHandler, }; this.fileAttachmentHandlers = config.fileAttachmentHandlers ?? { copy: attachmentHandlers.copyHandler, move: attachmentHandlers.moveHandler, ref: attachmentHandlers.referenceHandler, }; this.inferMimeType = config.inferMimeType ?? attachmentHandlers.inferMimeType; this.getNow = config.getNow; this.getReporterConfig = (0, utils_1.once)(config.getReporterConfig); this.getCurrentMetadata = () => new metadata_1.AllureTestItemMetadataProxy(config.getCurrentMetadata()); this.getFileMetadata = () => new metadata_1.AllureMetadataProxy(config.getFileMetadata()); this.getGlobalMetadata = () => new metadata_1.AllureMetadataProxy(config.getGlobalMetadata()); const taskQueue = new utils_1.TaskQueue({ logError(error) { logger_1.log.error(error, 'Allure Runtime Task Queue Error'); }, }); this.flush = taskQueue.flush; this.enqueueTask = taskQueue.enqueueTask; Object.defineProperty(this.contentAttachmentHandlers, 'default', { get: () => { const defaultName = this.getReporterConfig().attachments.contentHandler; return this.contentAttachmentHandlers[defaultName]; }, }); Object.defineProperty(this.fileAttachmentHandlers, 'default', { get: () => { const defaultName = this.getReporterConfig().attachments.fileHandler; return this.fileAttachmentHandlers[defaultName]; }, }); } } exports.AllureRuntimeContext = AllureRuntimeContext; //# sourceMappingURL=AllureRuntimeContext.js.map