UNPKG

e2ed

Version:

E2E testing framework over Playwright

26 lines (25 loc) 1.24 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.setDotEnvValuesToEnvironment = void 0; const internal_1 = require("../../constants/internal"); const error_1 = require("../error"); const getDotEnvValuesObject_1 = require("./getDotEnvValuesObject"); /** * Set values from `variables.env` file in directory with autotests to environment (to `process.env`). * @internal */ const setDotEnvValuesToEnvironment = async () => { // eslint-disable-next-line @typescript-eslint/unbound-method const { hasOwnProperty } = Object.prototype; const values = await (0, getDotEnvValuesObject_1.getDotEnvValuesObject)(); for (const [name, value] of Object.entries(values)) { if (hasOwnProperty.call(internal_1.e2edEnvironment, name) && internal_1.e2edEnvironment[name] !== value) { throw new error_1.E2edError(`Environment variable "${name}" from \`variables.env\` already defined in \`process.env\` with other value`, { valueFromDotEnv: value, valueFromProccessEnv: internal_1.e2edEnvironment[name], }); } internal_1.e2edEnvironment[name] = value; } }; exports.setDotEnvValuesToEnvironment = setDotEnvValuesToEnvironment;