UNPKG

@chtsinc/ch-playwright-report

Version:

Custom Playwright Reporter that logs test and execution results to MongoDB

56 lines 2.4 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.loadExecutionContext = loadExecutionContext; const fs_1 = __importDefault(require("fs")); const path_1 = __importDefault(require("path")); const dotenv_1 = __importDefault(require("dotenv")); const uuid_1 = require("uuid"); // Only load from .env if it exists and not already injected (like from Playwright) const dotenvPath = path_1.default.resolve(process.cwd(), ".env"); if (fs_1.default.existsSync(dotenvPath)) { dotenv_1.default.config({ override: false }); // Don’t override existing env vars } function getEnvVar(key, required = false) { const value = process.env[key]; if (value !== undefined && value.trim() !== "") { return value; } if (required) { throw new Error(`CHPlaywrightReporter: Environment variable ${key} is required but not provided.`); } return ""; } function loadExecutionContext() { return { executionId: getEnvVar("EXECUTION_ID") ? getEnvVar("EXECUTION_ID") : (0, uuid_1.v4)(), site: getEnvVar("SITE_NAME", true), os: getEnvVar("RIO_SELECTED_OS", true), subscriptionKey: getEnvVar("SUBSCRIPTION_KEY", true), browserName: getEnvVar("BROWSER"), project: getEnvVar("PROJECT_NAME"), siteShortName: getEnvVar("SITE_NAME"), siteURL: getEnvVar("SITE_URL"), environment: getEnvVar("ENVIRONMENT"), integration: getEnvVar("INTEGRATION"), group: getEnvVar("GROUP"), suite: getEnvVar("SUITE"), formFactor: getEnvVar("FORM_FACTOR"), osVersion: getEnvVar("OS_VERSION"), browserVersion: getEnvVar("BROWSER_VERSION"), device: getEnvVar("DEVICE"), deviceOrientation: getEnvVar("DEVICE_ORIENTATION"), autReleaseVersion: getEnvVar("AUT_RELEASE_VERSION"), tcReleaseVersion: getEnvVar("TC_RELEASE_VERSION"), user: getEnvVar("USER"), application_log_url: getEnvVar("APPLICATION_LOG_URL"), testType: getEnvVar("TEST_TYPE"), applicationName: getEnvVar("APPLICATION_NAME"), browserMobileEmulationName: getEnvVar("BROWSER_MOBILE_EMULATOR_NAME"), }; } //# sourceMappingURL=execution-context-loader.js.map