@@ -292,14 +292,14 @@ exports.setCypressConfigFilename = (bsConfig, args) => {
292292 bsConfig . run_settings . cypressProjectDir = path . dirname ( bsConfig . run_settings . cypress_config_file ) ;
293293 } else {
294294 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 ) {
295+ for ( const possibleCypressFileName of Constants . CYPRESS_CONFIG_FILE_NAMES ) {
296296 let directoryPath = ! this . isUndefined ( bsConfig . run_settings . cypress_proj_dir ) ? bsConfig . run_settings . cypress_proj_dir : process . cwd ( ) ;
297297 if ( directoryPath . endsWith ( "/" ) ) {
298- directoryPath
298+ directoryPath = directoryPath . slice ( 0 , - 1 ) ;
299299 }
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 } ` ;
300+ if ( fs . existsSync ( path . join ( directoryPath , possibleCypressFileName ) ) ) {
301+ bsConfig . run_settings . cypressConfigFilePath = `${ directoryPath } /${ possibleCypressFileName } ` ;
302+ bsConfig . run_settings . cypress_config_file = `${ directoryPath } /${ possibleCypressFileName } ` ;
303303 bsConfig . run_settings . cypress_config_filename = path . basename ( bsConfig . run_settings . cypress_config_file ) ;
304304 bsConfig . run_settings . cypressProjectDir = directoryPath ;
305305 break ;
@@ -312,11 +312,11 @@ exports.setCypressConfigFilename = (bsConfig, args) => {
312312}
313313
314314exports . setCypressTestSuiteType = ( bsConfig ) => {
315- for ( const possible_cypress_file_name of Constants . CYPRESS_CONFIG_FILE_NAMES ) {
315+ for ( const possibleCypressFileName of Constants . CYPRESS_CONFIG_FILE_NAMES ) {
316316 if ( bsConfig . run_settings . cypressConfigFilePath &&
317317 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 ;
318+ bsConfig . run_settings . cypressConfigFilePath . endsWith ( possibleCypressFileName ) ) {
319+ bsConfig . run_settings . cypressTestSuiteType = Constants . CYPRESS_CONFIG_FILE_MAPPING [ possibleCypressFileName ] . type ;
320320 break ;
321321 }
322322 }
@@ -393,8 +393,10 @@ exports.setProjectId = (bsConfig, args) => {
393393 } else if ( ! this . isUndefined ( bsConfig . run_settings [ "projectId" ] ) ) {
394394 return bsConfig . run_settings [ "projectId" ] ;
395395 } else {
396- let cypressJson = this . getCypressJSON ( bsConfig ) ;
397- if ( ! this . isUndefined ( cypressJson ) && ! this . isUndefined ( cypressJson [ "projectId" ] ) ) { return cypressJson [ "projectId" ] ; }
396+ let cypressConfigFile = this . getCypressConfigFile ( bsConfig ) ;
397+ if ( ! this . isUndefined ( cypressConfigFile ) && ! this . isUndefined ( cypressConfigFile [ "projectId" ] ) ) {
398+ return cypressConfigFile [ "projectId" ] ;
399+ }
398400 }
399401}
400402
@@ -950,8 +952,8 @@ exports.getFilesToIgnore = (runSettings, excludeFiles, logging = true) => {
950952 return ignoreFiles ;
951953}
952954
953- exports . getNumberOfSpecFiles = ( bsConfig , args , cypressJson ) => {
954- let testFolderPath = cypressJson . integrationFolder || Constants . DEFAULT_CYPRESS_SPEC_PATH ;
955+ exports . getNumberOfSpecFiles = ( bsConfig , args , cypressConfig ) => {
956+ let testFolderPath = cypressConfig . integrationFolder || Constants . DEFAULT_CYPRESS_SPEC_PATH ;
955957 let globSearchPattern = this . sanitizeSpecsPattern ( bsConfig . run_settings . specs ) || `${ testFolderPath } /**/*.+(${ Constants . specFileTypes . join ( "|" ) } )` ;
956958 let ignoreFiles = args . exclude || bsConfig . run_settings . exclude ;
957959 let files = glob . sync ( globSearchPattern , { cwd : bsConfig . run_settings . cypressProjectDir , matchBase : true , ignore : ignoreFiles } ) ;
@@ -1109,18 +1111,26 @@ exports.readBsConfigJSON = (bsConfigPath) => {
11091111 }
11101112}
11111113
1112- exports . getCypressJSON = ( bsConfig ) => {
1113- let cypressJSON = undefined ;
1114- if ( bsConfig . run_settings . cypress_config_file && bsConfig . run_settings . cypress_config_filename !== 'false' ) {
1115- cypressJSON = JSON . parse (
1116- fs . readFileSync ( bsConfig . run_settings . cypressConfigFilePath )
1117- ) ;
1118- } else if ( bsConfig . run_settings . cypressProjectDir ) {
1119- cypressJSON = JSON . parse (
1120- fs . readFileSync ( path . join ( bsConfig . run_settings . cypressProjectDir , bsConfig . run_settings . cypress_config_filename ) )
1121- ) ;
1114+ exports . getCypressConfigFile = ( bsConfig ) => {
1115+ let cypressConfigFile = undefined ;
1116+ if ( bsConfig . run_settings . cypressTestSuiteType === Constants . CYPRESS_V10_AND_ABOVE_TYPE ) {
1117+ if ( bsConfig . run_settings . cypress_config_filename . endsWith ( "cypress.config.js" ) ) {
1118+ if ( bsConfig . run_settings . cypress_config_file && bsConfig . run_settings . cypress_config_filename !== 'false' ) {
1119+ cypressConfigFile = require ( path . resolve ( bsConfig . run_settings . cypressConfigFilePath ) ) ;
1120+ } else if ( bsConfig . run_settings . cypressProjectDir ) {
1121+ cypressConfigFile = require ( path . join ( bsConfig . run_settings . cypressProjectDir , bsConfig . run_settings . cypress_config_filename ) ) ;
1122+ }
1123+ } else {
1124+ cypressConfigFile = { } ;
1125+ }
1126+ } else {
1127+ if ( bsConfig . run_settings . cypress_config_file && bsConfig . run_settings . cypress_config_filename !== 'false' ) {
1128+ cypressConfigFile = JSON . parse ( fs . readFileSync ( bsConfig . run_settings . cypressConfigFilePath ) )
1129+ } else if ( bsConfig . run_settings . cypressProjectDir ) {
1130+ cypressConfigFile = JSON . parse ( fs . readFileSync ( path . join ( bsConfig . run_settings . cypressProjectDir , bsConfig . run_settings . cypress_config_filename ) ) ) ;
1131+ }
11221132 }
1123- return cypressJSON ;
1133+ return cypressConfigFile ;
11241134}
11251135
11261136exports . setCLIMode = ( bsConfig , args ) => {
@@ -1254,13 +1264,13 @@ exports.fetchZipSize = (fileName) => {
12541264 }
12551265}
12561266
1257- exports . getVideoConfig = ( cypressJson ) => {
1267+ exports . getVideoConfig = ( cypressConfig ) => {
12581268 let conf = {
12591269 video : true ,
12601270 videoUploadOnPasses : true
12611271 }
1262- if ( ! this . isUndefined ( cypressJson . video ) ) conf . video = cypressJson . video ;
1263- if ( ! this . isUndefined ( cypressJson . videoUploadOnPasses ) ) conf . videoUploadOnPasses = cypressJson . videoUploadOnPasses ;
1272+ if ( ! this . isUndefined ( cypressConfig . video ) ) conf . video = cypressConfig . video ;
1273+ if ( ! this . isUndefined ( cypressConfig . videoUploadOnPasses ) ) conf . videoUploadOnPasses = cypressConfig . videoUploadOnPasses ;
12641274
12651275 logger . debug ( `Setting video = ${ conf . video } ` ) ;
12661276 logger . debug ( `Setting videoUploadOnPasses = ${ conf . videoUploadOnPasses } ` ) ;
0 commit comments