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.
This commit is contained in:
parent
96376be0e3
commit
07fe97165e
1 changed files with 8 additions and 5 deletions
|
|
@ -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' });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue