jest-allure2-reporter
Version:
Idiomatic Jest reporter for Allure Framework
12 lines (9 loc) • 510 B
text/typescript
import path from 'node:path';
import { randomUUID } from 'node:crypto';
import type { AttachmentContext, ContentAttachmentContext, FileAttachmentContext } from '../types';
import { getFullExtension } from '../../utils';
export function placeAttachment(context: AttachmentContext): string {
const { outDir, name, sourcePath } = context as FileAttachmentContext & ContentAttachmentContext;
const fileName = name || sourcePath || '';
return path.join(outDir, randomUUID() + getFullExtension(fileName));
}