playwright-zephyr
Version:
Zephyr reporter for the Playwright
23 lines (22 loc) • 812 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.createJsonReport = createJsonReport;
const fs_1 = require("fs");
const path_1 = require("path");
function createJsonReport(filename, filePath, executionResults) {
const jsonReport = JSON.stringify({ version: 1, executions: executionResults }, null, 2);
const jsonReportPath = (0, path_1.join)(process.cwd(), filePath, filename);
try {
createDirectory(filePath);
(0, fs_1.writeFileSync)(jsonReportPath, jsonReport);
}
catch (error) {
console.log(`Something went wrong while creating the report. ${error}`);
throw error;
}
}
function createDirectory(filePath) {
if (!(0, fs_1.existsSync)(filePath)) {
(0, fs_1.mkdirSync)(filePath, { recursive: true });
}
}