UNPKG

tm-playwright-framework

Version:

Playwright Cucumber TS framework - The easiest way to learn

61 lines (60 loc) 2.62 kB
/** * REPORT.TS * * This TypeScript file contains Cucumber report generation logic using `multiple-cucumber-html-reporter`. * * @author Sasitharan, Govindharam * @reviewer Sahoo, AshokKumar * @version 1.0 - 1st-JUNE-2025 * * @methods * - `log`: Method to log the message based on status received * - `logStatus`: Method to receive the message along with the status to log the message as info or error */ import * as report from 'multiple-cucumber-html-reporter'; import { release, type, userInfo, arch, hostname } from 'os'; import fs from "fs"; const customData = JSON.parse(fs.readFileSync('app/report-data.json', 'utf8')); const args = process.argv.slice(2); // Get arguments excluding 'node' and script path const parsedArgs = {}; // Loop through the arguments and split them into key-value pairs args.forEach(arg => { const [key, value] = arg.split('='); parsedArgs[key] = value; }); const REPORT_JSON_PATH = parsedArgs["REPORT_PATH"] || `${process.env.REPORT_PATH}`; console.log(`REPORT_JSON_PATH1: ${REPORT_JSON_PATH}`); report.generate({ jsonDir: REPORT_JSON_PATH, reportPath: `${REPORT_JSON_PATH}/../multiple-cucumber-report/`, reportName: "Cucumber Automation Report", pageTitle: `${customData.Value1} - Automation Report`, displayDuration: true, metadata: { browser: { name: `${parsedArgs["BROWSER"]}`, version: `${parsedArgs["VERSION"]}`, headless: `${parsedArgs["HEADLESS"]}`, }, device: `${hostname}`, platform: { name: `${type()} ${arch()}`, version: `${release()}` }, }, customData: { title: "Test Info", data: [ { label: `${customData.Label1}`, value: `${customData.Value1}` }, { label: "ENV", value: `${parsedArgs["ENV"]}` }, { label: "FEATURES", value: `${parsedArgs["FEATURES"]}` }, { label: "TAGS", value: `${parsedArgs["TAGS"]}` }, { label: "USER", value: `${userInfo().username}` }, { label: `${customData.Label2 ? customData.Label2 : ''}`, value: `${customData.Value2 ? customData.Value2 : ''}` }, { label: `${customData.Label3 ? customData.Label3 : ''}`, value: `${customData.Value3 ? customData.Value3 : ''}` }, { label: `${customData.Label4 ? customData.Label4 : ''}`, value: `${customData.Value3 ? customData.Value4 : ''}` }, { label: `${customData.Label5 ? customData.Label5 : ''}`, value: `${customData.Value3 ? customData.Value5 : ''}` } ], }, }); console.log(`REPORT_JSON_PATH2: ${REPORT_JSON_PATH}`);