@allurereport/plugin-classic
Version:
The classic version of Allure HTML report
57 lines (56 loc) • 1.52 kB
JavaScript
import MarkdownIt from "markdown-it";
const md = new MarkdownIt();
const markdownToHtml = (value) => (value ? md.render(value) : undefined);
const mapLabelsByName = (labels) => {
return labels.reduce((acc, { name, value }) => {
acc[name] = acc[name] || [];
if (value) {
acc[name].push(value);
}
return acc;
}, {});
};
export const convertTestResult = (tr) => {
return {
id: tr.id,
name: tr.name,
start: tr.start,
stop: tr.stop,
duration: tr.duration,
status: tr.status,
fullName: tr.fullName,
historyId: tr.historyId,
flaky: tr.flaky,
muted: tr.muted,
known: tr.known,
hidden: tr.hidden,
labels: tr.labels,
groupedLabels: mapLabelsByName(tr.labels),
parameters: tr.parameters,
links: tr.links,
steps: tr.steps,
error: tr.error,
testCase: tr.testCase,
descriptionHtml: tr.descriptionHtml ?? markdownToHtml(tr.description),
setup: [],
teardown: [],
history: [],
retries: [],
breadcrumbs: [],
retry: false,
transition: tr.transition,
};
};
export const convertTestStepResult = (tsr) => {
return tsr;
};
export const convertFixtureResult = (fr) => {
return {
id: fr.id,
type: fr.type,
name: fr.name,
status: fr.status,
steps: fr.steps.map(convertTestStepResult),
duration: fr.duration,
};
};