UNPKG

e2ed

Version:

E2E testing framework over Playwright

27 lines (26 loc) 1.39 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.writeLiteJsonReport = void 0; const node_path_1 = require("node:path"); const internal_1 = require("../../constants/internal"); const fs_1 = require("../fs"); const generalLog_1 = require("../generalLog"); const getDurationWithUnits_1 = require("../getDurationWithUnits"); const bytesInKiB = 1_024; /** * Writes lite JSON report (`lite-report.json` file) with test runs results * (and without test run logs). * @internal */ const writeLiteJsonReport = async (liteReport) => { const startTimeInMs = Date.now(); const { liteReportFileName } = liteReport; const reportJson = JSON.stringify(liteReport); const reportFilePath = (0, node_path_1.join)(internal_1.ABSOLUTE_PATH_TO_PROJECT_ROOT_DIRECTORY, internal_1.REPORTS_DIRECTORY_PATH, liteReportFileName); await (0, fs_1.writeFile)(reportFilePath, reportJson); const reportFileSizeInBytes = await (0, fs_1.getFileSize)(reportFilePath); const reportFileSizeInKiB = (reportFileSizeInBytes / bytesInKiB).toFixed(2); const durationWithUnits = (0, getDurationWithUnits_1.getDurationWithUnits)(Date.now() - startTimeInMs); (0, generalLog_1.generalLog)(`Lite JSON report was written (${reportFileSizeInKiB} KiB) to "file://${reportFilePath}" in ${durationWithUnits}`); }; exports.writeLiteJsonReport = writeLiteJsonReport;