jest-allure2-reporter
Version:
Idiomatic Jest reporter for Allure Framework
30 lines (26 loc) • 1.09 kB
text/typescript
import type {
AllureTestStepMetadata,
TestStepCustomizer,
TestStepExtractorContext,
Stage,
Status,
} from 'jest-allure2-reporter';
export const testStep: TestStepCustomizer<TestStepExtractorContext> = {
ignored: () => false,
displayName: ({ testStepMetadata }) =>
testStepMetadata.displayName || testStepMetadata.hookType || 'Untitled step',
start: ({ testStepMetadata }) => testStepMetadata.start!,
stop: ({ testStepMetadata }) => testStepMetadata.stop!,
stage: ({ testStepMetadata }) => testStepMetadata.stage!,
status: ({ testStepMetadata }) => testStepMetadata.status ?? inferStatus(testStepMetadata),
statusDetails: ({ testStepMetadata }) => testStepMetadata.statusDetails ?? {},
attachments: ({ testStepMetadata }) => testStepMetadata.attachments ?? [],
parameters: ({ testStepMetadata }) => testStepMetadata.parameters ?? [],
};
function inferStatus({ stage }: AllureTestStepMetadata): Status {
return (stage && statuses[stage]) || 'unknown';
}
const statuses: Partial<Record<Stage, Status>> = {
finished: 'passed',
interrupted: 'broken',
};