@@ -5,10 +5,13 @@ import fs from 'fs';
55import path from 'path' ;
66import { inputValues } from '@config' ;
77import { requireEnv } from '@utils/env.utils' ;
8+ import { createLogger } from '@utils/logger' ;
89
910import MagentoAdminPage from '@poms/adminhtml/magentoAdmin.page' ;
1011import RegisterPage from '@poms/frontend/register.page' ;
1112
13+ const logger = createLogger ( 'Setup' ) ;
14+
1215const magentoAdminUsername = requireEnv ( 'MAGENTO_ADMIN_USERNAME' ) ;
1316const magentoAdminPassword = requireEnv ( 'MAGENTO_ADMIN_PASSWORD' ) ;
1417
@@ -66,28 +69,27 @@ base.describe('Setting up the testing environment', () => {
6669 ) ;
6770 } ) ;
6871
69- await base . step ( `Step 2: (optional) Update env file` , async ( ) => {
70- console . log ( process . env . CI ) ;
71- if ( process . env . CI === 'true' ) {
72- console . log ( "Running in CI environment. Skipping .env update." ) ;
73- base . skip ( ) ;
74- }
75-
76- const envPath = path . resolve ( __dirname , '../.env' ) ;
77- try {
78- if ( fs . existsSync ( envPath ) ) {
79- const envContent = fs . readFileSync ( envPath , 'utf-8' ) ;
80- if ( ! envContent . includes ( `SETUP_COMPLETE_${ browserEngine } ='DONE'` ) ) {
81- fs . appendFileSync ( envPath , `\nSETUP_COMPLETE_${ browserEngine } ='DONE'` ) ;
82- console . log ( `Environment setup completed. Added SETUP_COMPLETE_${ browserEngine } ='DONE' to .env` ) ;
72+ await base . step ( `Step 2: (optional) Update env file` , async ( ) => {
73+ if ( process . env . CI === 'true' ) {
74+ logger . info ( "Running in CI environment. Skipping .env update." ) ;
75+ base . skip ( ) ;
76+ }
77+
78+ const envPath = path . resolve ( __dirname , '../.env' ) ;
79+ try {
80+ if ( fs . existsSync ( envPath ) ) {
81+ const envContent = fs . readFileSync ( envPath , 'utf-8' ) ;
82+ if ( ! envContent . includes ( `SETUP_COMPLETE_${ browserEngine } ='DONE'` ) ) {
83+ fs . appendFileSync ( envPath , `\nSETUP_COMPLETE_${ browserEngine } ='DONE'` ) ;
84+ logger . info ( `Environment setup completed. Added SETUP_COMPLETE_${ browserEngine } ='DONE' to .env` ) ;
85+ }
86+ } else {
87+ throw new Error ( '.env file not found. Please ensure it exists in the root directory.' ) ;
8388 }
84- } else {
85- throw new Error ( '.env file not found. Please ensure it exists in the root directory.' ) ;
89+ } catch ( error ) {
90+ const err = error as Error ;
91+ throw new Error ( `Failed to update .env file: ${ err . message } ` ) ;
8692 }
87- } catch ( error ) {
88- const err = error as Error ;
89- throw new Error ( `Failed to update .env file: ${ err . message } ` ) ;
90- }
9193 } ) ;
9294 } ) ;
9395} ) ;
0 commit comments