askui
Version:
Reliable, automated end-to-end-testing that depends on what is shown on your screen instead of the technology you are running on
17 lines (16 loc) • 743 B
JavaScript
import fs from 'fs';
import path from 'path';
import { logger } from '../../lib/logger';
export class AnnotationWriter {
static write(html, outputFolder = 'report', fileNamePrefix = 'annotation') {
const currentDateTime = new Date();
const currentTimeStringOnlyNumbers = currentDateTime.toISOString().replace(/\D/g, '');
const fileName = `${currentTimeStringOnlyNumbers}_${fileNamePrefix}.html`;
const outputFilePath = path.join(outputFolder, fileName);
if (!(fs.existsSync(outputFolder))) {
fs.mkdirSync(outputFolder, { recursive: true });
}
fs.writeFileSync(outputFilePath, html.serialize());
logger.info(`Annotation saved under "${outputFilePath}".`);
}
}