e2ed
Version:
E2E testing framework over Playwright
29 lines (28 loc) • 1.55 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.writeHtmlReport = void 0;
const node_path_1 = require("node:path");
const internal_1 = require("../../constants/internal");
const asserts_1 = require("../asserts");
const fs_1 = require("../fs");
const generalLog_1 = require("../generalLog");
const getDurationWithUnits_1 = require("../getDurationWithUnits");
const getFileSizeInMb_1 = require("../getFileSizeInMb");
const render_1 = require("./render");
/**
* Writes HTML report (`report.html` file) with test runs results.
* @internal
*/
const writeHtmlReport = async (reportData) => {
const startTimeInMs = Date.now();
const reportHtml = (0, render_1.renderReportToHtml)(reportData);
const { reportFileName } = reportData;
(0, asserts_1.assertValueIsNotNull)(reportFileName, 'reportFileName is not null');
const reportFilePath = (0, node_path_1.join)(internal_1.ABSOLUTE_PATH_TO_PROJECT_ROOT_DIRECTORY, internal_1.REPORTS_DIRECTORY_PATH, reportFileName);
await (0, fs_1.writeFile)(reportFilePath, String(reportHtml));
const reportFileSizeInBytes = await (0, fs_1.getFileSize)(reportFilePath);
const reportFileSizeInMb = (0, getFileSizeInMb_1.getFileSizeInMb)(reportFileSizeInBytes);
const durationWithUnits = (0, getDurationWithUnits_1.getDurationWithUnits)(Date.now() - startTimeInMs);
(0, generalLog_1.generalLog)(`HTML report was written (${reportFileSizeInMb}) to "file://${reportFilePath}" in ${durationWithUnits}`);
};
exports.writeHtmlReport = writeHtmlReport;