jest-allure2-reporter
Version:
Idiomatic Jest reporter for Allure Framework
15 lines (11 loc) • 530 B
text/typescript
import path from 'node:path';
import fs from 'node:fs/promises';
import type { ContentAttachmentHandler } from '../types';
import { placeAttachment } from './placeAttachment';
export const writeHandler: ContentAttachmentHandler = async (context) => {
const destination = placeAttachment(context);
await fs.mkdir(path.dirname(destination), { recursive: true });
await fs.writeFile(destination, context.content);
const size = context.size ?? Buffer.byteLength(context.content);
return { source: destination, size };
};