UNPKG

jest-allure2-reporter

Version:
33 lines (27 loc) 709 B
import type { AllureTestCaseResult, Label } from 'jest-allure2-reporter'; const SINGLE_LABELS = new Set([ 'owner', 'package', 'parentSuite', 'severity', 'subSuite', 'suite', 'testClass', 'testMethod', 'thread', ]); export function normalizeLabels(test: AllureTestCaseResult) { if (test.labels) { const accumulator: Record<string, Label[]> = {}; for (const label of test.labels) { if (SINGLE_LABELS.has(label.name)) { accumulator[label.name] = [label]; } else { accumulator[label.name] = accumulator[label.name] || []; accumulator[label.name].push(label); } } return Object.values<Label[]>(accumulator).flat(); } return; }