1- const { join } = require ( " path" ) ;
2- const filter = require ( " lodash/filter" ) ;
3- const forEach = require ( " lodash/forEach" ) ;
4- const isEmpty = require ( " lodash/isEmpty" ) ;
5- const isArray = require ( " lodash/isArray" ) ;
6- const includes = require ( " lodash/includes" ) ;
7- const { existsSync, readdirSync } = require ( "fs" ) ;
1+ const { join } = require ( ' path' ) ;
2+ const filter = require ( ' lodash/filter' ) ;
3+ const forEach = require ( ' lodash/forEach' ) ;
4+ const isEmpty = require ( ' lodash/isEmpty' ) ;
5+ const isArray = require ( ' lodash/isArray' ) ;
6+ const includes = require ( ' lodash/includes' ) ;
7+ const { existsSync, readdirSync } = require ( 'fs' ) ;
88
9- const { initEnvData, getLoginCredentials } = require ( './integration/utils/helper' )
10- const { INTEGRATION_EXECUTION_ORDER , IS_TS , ENABLE_PREREQUISITES } = require ( " ./config.json" ) ;
9+ const { initEnvData, getLoginCredentials } = require ( './integration/utils/helper' ) ;
10+ const { INTEGRATION_EXECUTION_ORDER , IS_TS , ENABLE_PREREQUISITES } = require ( ' ./config.json' ) ;
1111
1212// NOTE init env variables
13- require ( 'dotenv-expand' ) . expand ( require ( 'dotenv' ) . config ( ) )
13+ require ( 'dotenv-expand' ) . expand ( require ( 'dotenv' ) . config ( ) ) ;
1414// require('dotenv').config({ path: resolve(process.cwd(), '.env.test') })
1515
1616const { INTEGRATION_TEST } = process . env ;
1717
18- initEnvData ( ) // NOTE Prepare env data
18+ initEnvData ( ) ; // NOTE Prepare env data
1919
2020const args = process . argv . slice ( 2 ) ;
21- const testFileExtension = IS_TS ? '.ts' : '.js'
21+ const testFileExtension = IS_TS ? '.ts' : '.js' ;
2222
2323/**
2424 * @method getFileName
2525 * @param {string } file
2626 * @returns {string }
2727 */
2828const getFileName = ( file ) => {
29- if ( includes ( file , " .test" ) && includes ( file , testFileExtension ) ) return file ;
30- else if ( includes ( file , " .test" ) ) return `${ file } ${ testFileExtension } ` ;
31- else if ( ! includes ( file , " .test" ) ) return `${ file } .test${ testFileExtension } ` ;
29+ if ( includes ( file , ' .test' ) && includes ( file , testFileExtension ) ) return file ;
30+ else if ( includes ( file , ' .test' ) ) return `${ file } ${ testFileExtension } ` ;
31+ else if ( ! includes ( file , ' .test' ) ) return `${ file } .test${ testFileExtension } ` ;
3232 else return `${ file } .test${ testFileExtension } ` ;
3333} ;
3434
3535/**
3636 * @method includeInitFileIfExist
37- * @param {String } basePath
37+ * @param {String } basePath
3838 */
3939const includeInitFileIfExist = ( basePath , region ) => {
4040 const filePath = join ( __dirname , basePath , `init.test${ testFileExtension } ` ) ;
@@ -43,14 +43,14 @@ const includeInitFileIfExist = (basePath, region) => {
4343 if ( existsSync ( filePath ) ) {
4444 require ( filePath ) ( region ) ;
4545 }
46- } catch ( err ) {
47- debugger
46+ } catch ( err ) {
47+ console . error ( err . message ) ;
4848 }
49- }
49+ } ;
5050
5151/**
5252 * @method includeCleanUpFileIfExist
53- * @param {String } basePath
53+ * @param {String } basePath
5454 */
5555const includeCleanUpFileIfExist = async ( basePath , region ) => {
5656 const filePath = join ( __dirname , basePath , `clean-up.test${ testFileExtension } ` ) ;
@@ -59,25 +59,26 @@ const includeCleanUpFileIfExist = async (basePath, region) => {
5959 if ( existsSync ( filePath ) ) {
6060 require ( filePath ) ( region ) ;
6161 }
62- } catch ( err ) { }
63- }
62+ } catch ( err ) { }
63+ } ;
6464
6565/**
6666 * @method includeTestFiles
6767 * @param {Array<string> } files
6868 * @param {string } basePath
6969 */
70- const includeTestFiles = async ( files , basePath = " integration" ) => {
70+ const includeTestFiles = async ( files , basePath = ' integration' ) => {
7171 let regions = getLoginCredentials ( ) ;
7272 for ( let region of Object . keys ( regions ) ) {
7373 if ( ENABLE_PREREQUISITES ) {
74- includeInitFileIfExist ( basePath , regions [ region ] ) // NOTE Run all the pre configurations
74+ includeInitFileIfExist ( basePath , regions [ region ] ) ; // NOTE Run all the pre configurations
7575 }
7676
77- files = filter ( files , ( name ) => (
78- ! includes ( `init.test${ testFileExtension } ` , name ) &&
79- ! includes ( `clean-up.test${ testFileExtension } ` , name )
80- ) ) // NOTE remove init, clean-up files
77+ files = filter (
78+ files ,
79+ ( name ) =>
80+ ! includes ( name , `init.test${ testFileExtension } ` ) && ! includes ( name , `clean-up.test${ testFileExtension } ` ) ,
81+ ) ; // NOTE remove init, clean-up files
8182
8283 forEach ( files , ( file ) => {
8384 const filename = getFileName ( file ) ;
@@ -89,11 +90,11 @@ const includeTestFiles = async (files, basePath = "integration") => {
8990 console . error ( `File not found - ${ filename } ` ) ;
9091 }
9192 } catch ( err ) {
92- console . err ( err . message )
93+ console . error ( err . message ) ;
9394 }
9495 } ) ;
9596
96- await includeCleanUpFileIfExist ( basePath , regions [ region ] ) // NOTE run all cleanup code/commands
97+ await includeCleanUpFileIfExist ( basePath , regions [ region ] ) ; // NOTE run all cleanup code/commands
9798 }
9899} ;
99100
@@ -102,18 +103,15 @@ const includeTestFiles = async (files, basePath = "integration") => {
102103 * @param {Array<string> | undefined | null | unknown } executionOrder
103104 * @param {boolean } isIntegrationTest
104105 */
105- const run = (
106- executionOrder ,
107- isIntegrationTest = true
108- ) => {
109- const testFolder = isIntegrationTest ? "integration" : "unit" ;
106+ const run = ( executionOrder , isIntegrationTest = true ) => {
107+ const testFolder = isIntegrationTest ? 'integration' : 'unit' ;
110108
111109 if ( isArray ( executionOrder ) && ! isEmpty ( executionOrder ) ) {
112110 includeTestFiles ( executionOrder , testFolder ) ;
113111 } else {
114112 const basePath = join ( __dirname , testFolder ) ;
115113 const allIntegrationTestFiles = filter ( readdirSync ( basePath ) , ( file ) =>
116- includes ( file , `.test${ testFileExtension } ` )
114+ includes ( file , `.test${ testFileExtension } ` ) ,
117115 ) ;
118116
119117 includeTestFiles ( allIntegrationTestFiles ) ;
@@ -122,7 +120,7 @@ const run = (
122120
123121if ( INTEGRATION_TEST === 'true' ) {
124122 run ( INTEGRATION_EXECUTION_ORDER ) ;
125- } else if ( includes ( args , " --unit-test" ) ) {
123+ } else if ( includes ( args , ' --unit-test' ) ) {
126124 // NOTE unit test case will be handled here
127125 // run(UNIT_EXECUTION_ORDER, false);
128126}
0 commit comments