e2ed
Version:
E2E testing framework over Playwright
27 lines (26 loc) • 1.15 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.writeTestRunToJsonFile = void 0;
const promises_1 = require("node:fs/promises");
const node_path_1 = require("node:path");
const internal_1 = require("../../constants/internal");
const error_1 = require("../error");
const getTestRunEventFileName_1 = require("./getTestRunEventFileName");
const writeFile_1 = require("./writeFile");
/**
* Writes completed (full) test run object to temporary JSON file.
* @internal
*/
const writeTestRunToJsonFile = async (fullTestRun) => {
const { runId } = fullTestRun;
const fileName = (0, getTestRunEventFileName_1.getTestRunEventFileName)(runId);
const filePath = (0, node_path_1.join)(internal_1.EVENTS_DIRECTORY_PATH, fileName);
await (0, promises_1.stat)(filePath).then((stats) => {
throw new error_1.E2edError(`Test run JSON file ${filePath} already exists in temporary directory`, {
stats,
});
}, () => undefined);
const data = JSON.stringify(fullTestRun);
await (0, writeFile_1.writeFile)(filePath, data);
};
exports.writeTestRunToJsonFile = writeTestRunToJsonFile;