jest-allure2-reporter
Version:
Idiomatic Jest reporter for Allure Framework
68 lines • 3.36 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.MetadataSquasher = void 0;
const tslib_1 = require("tslib");
const constants_1 = require("../constants");
const docblock = tslib_1.__importStar(require("../docblockMapping"));
const MetadataSelector_1 = require("./MetadataSelector");
const mergers_1 = require("./mergers");
class MetadataSquasher {
_fileSelector;
_testSelector;
_stepSelector;
constructor() {
this._fileSelector = new MetadataSelector_1.MetadataSelector({
empty: () => ({}),
getDocblock: (metadata) => docblock.mapTestFileDocblock(metadata.get(constants_1.DOCBLOCK, {})),
getMetadata: (metadata) => metadata.get(constants_1.PREFIX),
mergeUnsafe: mergers_1.mergeTestFileMetadata,
});
this._testSelector = new MetadataSelector_1.MetadataSelector({
empty: () => ({}),
getDocblock: (metadata) => docblock.mapTestCaseDocblock(metadata.get(constants_1.DOCBLOCK, {})),
getMetadata: (metadata) => metadata.get(constants_1.PREFIX),
mergeUnsafe: mergers_1.mergeTestCaseMetadata,
});
this._stepSelector = new MetadataSelector_1.MetadataSelector({
empty: () => ({}),
getDocblock: (metadata) => docblock.mapTestStepDocblock(metadata.get(constants_1.DOCBLOCK, {})),
getMetadata: (metadata) => metadata.get(constants_1.PREFIX),
mergeUnsafe: mergers_1.mergeTestStepMetadata,
});
}
testFile(jest_metadata) {
const result = {
...this._fileSelector.globalAndTestFile(jest_metadata),
steps: this._stepSelector.getMetadataWithDocblock(jest_metadata).steps,
};
return result;
}
testInvocation(invocation) {
const test_vertical = this._testSelector.testVertical(invocation);
const test_definition_and_below = this._testSelector.testDefinitionAndBelow(invocation);
const test_definition_and_below_direct = this._testSelector.testDefinitionAndBelowDirect(invocation);
const test_invocation_and_below = this._testSelector.testInvocationAndBelow(invocation);
const result = {
attachments: test_definition_and_below_direct.attachments,
description: test_vertical.description,
descriptionHtml: test_vertical.descriptionHtml,
displayName: test_definition_and_below_direct.displayName,
fullName: test_definition_and_below.fullName,
historyId: test_definition_and_below.historyId,
labels: test_vertical.labels,
links: test_vertical.links,
parameters: test_definition_and_below_direct.parameters,
sourceLocation: test_definition_and_below_direct.sourceLocation,
stage: test_invocation_and_below.stage,
start: test_invocation_and_below.start,
status: test_invocation_and_below.status,
statusDetails: test_invocation_and_below.statusDetails,
steps: this._stepSelector.steps(invocation),
stop: test_invocation_and_below.stop,
transformedCode: test_definition_and_below_direct.transformedCode,
};
return result;
}
}
exports.MetadataSquasher = MetadataSquasher;
//# sourceMappingURL=MetadataSquasher.js.map