@@ -57,6 +57,9 @@ exports.getErrorCodeFromMsg = (errMsg) => {
5757 case Constants . validationMessages . EMPTY_CYPRESS_PROJ_DIR :
5858 errorCode = 'bstack_json_invalid_no_cypress_proj_dir' ;
5959 break ;
60+ case Constants . validationMessages . EMPTY_CYPRESS_CONFIG_FILE :
61+ errorCode = 'bstack_json_invalid_no_cypress_config_file' ;
62+ break ;
6063 case Constants . validationMessages . INVALID_DEFAULT_AUTH_PARAMS :
6164 errorCode = 'bstack_json_default_auth_keys' ;
6265 break ;
@@ -288,13 +291,43 @@ exports.setCypressConfigFilename = (bsConfig, args) => {
288291 bsConfig . run_settings . cypressConfigFilePath = bsConfig . run_settings . cypress_config_file ;
289292 bsConfig . run_settings . cypressProjectDir = path . dirname ( bsConfig . run_settings . cypress_config_file ) ;
290293 } else {
291- bsConfig . run_settings . cypressConfigFilePath = path . join ( bsConfig . run_settings . cypress_proj_dir , 'cypress.json' ) ;
292- bsConfig . run_settings . cypressProjectDir = bsConfig . run_settings . cypress_proj_dir ;
294+ logger . debug ( `Looks like cypress config file was not provided. Looking for ${ Constants . CYPRESS_CONFIG_FILE_NAMES . join ( ", " ) } files at ${ process . cwd ( ) } ` ) ;
295+ for ( const possible_cypress_file_name of Constants . CYPRESS_CONFIG_FILE_NAMES ) {
296+ let directoryPath = ! this . isUndefined ( bsConfig . run_settings . cypress_proj_dir ) ? bsConfig . run_settings . cypress_proj_dir : process . cwd ( ) ;
297+ if ( directoryPath . endsWith ( "/" ) ) {
298+ directoryPath
299+ }
300+ if ( fs . existsSync ( path . join ( directoryPath , possible_cypress_file_name ) ) ) {
301+ bsConfig . run_settings . cypressConfigFilePath = `${ directoryPath } /${ possible_cypress_file_name } ` ;
302+ bsConfig . run_settings . cypress_config_file = `${ directoryPath } /${ possible_cypress_file_name } ` ;
303+ bsConfig . run_settings . cypress_config_filename = path . basename ( bsConfig . run_settings . cypress_config_file ) ;
304+ bsConfig . run_settings . cypressProjectDir = directoryPath ;
305+ break ;
306+ }
307+ }
293308 }
309+
294310 logger . debug ( `Setting cypress config file path = ${ bsConfig . run_settings . cypressConfigFilePath } ` ) ;
295311 logger . debug ( `Setting cypress project dir = ${ bsConfig . run_settings . cypressProjDir } ` ) ;
296312}
297313
314+ exports . setCypressTestSuiteType = ( bsConfig ) => {
315+ for ( const possible_cypress_file_name of Constants . CYPRESS_CONFIG_FILE_NAMES ) {
316+ if ( bsConfig . run_settings . cypressConfigFilePath &&
317+ typeof ( bsConfig . run_settings . cypressConfigFilePath ) === 'string' &&
318+ bsConfig . run_settings . cypressConfigFilePath . endsWith ( possible_cypress_file_name ) ) {
319+ bsConfig . run_settings . cypressTestSuiteType = Constants . CYPRESS_CONFIG_FILE_MAPPING [ possible_cypress_file_name ] . type ;
320+ break ;
321+ }
322+ }
323+
324+ if ( this . isUndefined ( bsConfig . run_settings . cypressTestSuiteType ) ) {
325+ bsConfig . run_settings . cypressTestSuiteType = Constants . CYPRESS_V9_AND_OLDER_TYPE ;
326+ }
327+
328+ logger . debug ( `Setting cypress test suite type as ${ bsConfig . run_settings . cypressTestSuiteType } ` ) ;
329+ }
330+
298331exports . verifyGeolocationOption = ( ) => {
299332 let glOptionsSet = ( this . searchForOption ( '-gl' ) || this . searchForOption ( '--gl' ) ) ;
300333 let geoHyphenLocationOptionsSet = ( this . searchForOption ( '-geo-location' ) || this . searchForOption ( '--geo-location' ) ) ;
@@ -1084,7 +1117,7 @@ exports.getCypressJSON = (bsConfig) => {
10841117 ) ;
10851118 } else if ( bsConfig . run_settings . cypressProjectDir ) {
10861119 cypressJSON = JSON . parse (
1087- fs . readFileSync ( path . join ( bsConfig . run_settings . cypressProjectDir , 'cypress.json' ) )
1120+ fs . readFileSync ( path . join ( bsConfig . run_settings . cypressProjectDir , bsConfig . run_settings . cypress_config_filename ) )
10881121 ) ;
10891122 }
10901123 return cypressJSON ;
0 commit comments