From 07fe97165e01e61656b2d937f73ac58750807dd1 Mon Sep 17 00:00:00 2001 From: maguire-arman Date: Tue, 8 Apr 2025 09:26:27 -0400 Subject: [PATCH] Loads env vars only when not in CI Ensures environment variables are loaded from `.env` files only when not running in a CI environment. This prevents overwriting variables already present in the CI environment. Adds an example env file for local development. --- playwright-tests/playwright.config.ts | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/playwright-tests/playwright.config.ts b/playwright-tests/playwright.config.ts index 9ecdf749a..3adfb38aa 100644 --- a/playwright-tests/playwright.config.ts +++ b/playwright-tests/playwright.config.ts @@ -2,11 +2,14 @@ import { defineConfig, devices } from '@playwright/test'; import dotenv from 'dotenv-safe'; import { OrtoniReportConfig } from "ortoni-report"; -if (process.env.NODE_ENV == 'undefined' || process.env.NODE_ENV == null) { - dotenv.config({ path: `./.env.dev` }); -} -else { - dotenv.config({ path: `./.env.${process.env.NODE_ENV}` }); +if (!process.env.CI) { + // Environment variables are present in CI environment, no need to read from file + if (process.env.NODE_ENV == 'undefined' || process.env.NODE_ENV == null) { + dotenv.config({ path: `playwright-tests/.env.dev`, example: 'playwright-tests/.env.example' }); + } + else { + dotenv.config({ path: `playwright-tests/.env.${process.env.NODE_ENV}`, example: 'playwright-tests/.env.example' }); + } }