@@ -292,14 +292,14 @@ exports.setCypressConfigFilename = (bsConfig, args) => {
292
292
bsConfig . run_settings . cypressProjectDir = path . dirname ( bsConfig . run_settings . cypress_config_file ) ;
293
293
} else {
294
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 ) {
295
+ for ( const possibleCypressFileName of Constants . CYPRESS_CONFIG_FILE_NAMES ) {
296
296
let directoryPath = ! this . isUndefined ( bsConfig . run_settings . cypress_proj_dir ) ? bsConfig . run_settings . cypress_proj_dir : process . cwd ( ) ;
297
297
if ( directoryPath . endsWith ( "/" ) ) {
298
- directoryPath
298
+ directoryPath = directoryPath . slice ( 0 , - 1 ) ;
299
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 } ` ;
300
+ if ( fs . existsSync ( path . join ( directoryPath , possibleCypressFileName ) ) ) {
301
+ bsConfig . run_settings . cypressConfigFilePath = `${ directoryPath } /${ possibleCypressFileName } ` ;
302
+ bsConfig . run_settings . cypress_config_file = `${ directoryPath } /${ possibleCypressFileName } ` ;
303
303
bsConfig . run_settings . cypress_config_filename = path . basename ( bsConfig . run_settings . cypress_config_file ) ;
304
304
bsConfig . run_settings . cypressProjectDir = directoryPath ;
305
305
break ;
@@ -312,11 +312,11 @@ exports.setCypressConfigFilename = (bsConfig, args) => {
312
312
}
313
313
314
314
exports . 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 ) {
316
316
if ( bsConfig . run_settings . cypressConfigFilePath &&
317
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 ;
318
+ bsConfig . run_settings . cypressConfigFilePath . endsWith ( possibleCypressFileName ) ) {
319
+ bsConfig . run_settings . cypressTestSuiteType = Constants . CYPRESS_CONFIG_FILE_MAPPING [ possibleCypressFileName ] . type ;
320
320
break ;
321
321
}
322
322
}
@@ -393,8 +393,10 @@ exports.setProjectId = (bsConfig, args) => {
393
393
} else if ( ! this . isUndefined ( bsConfig . run_settings [ "projectId" ] ) ) {
394
394
return bsConfig . run_settings [ "projectId" ] ;
395
395
} 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
+ }
398
400
}
399
401
}
400
402
@@ -950,8 +952,8 @@ exports.getFilesToIgnore = (runSettings, excludeFiles, logging = true) => {
950
952
return ignoreFiles ;
951
953
}
952
954
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 ;
955
957
let globSearchPattern = this . sanitizeSpecsPattern ( bsConfig . run_settings . specs ) || `${ testFolderPath } /**/*.+(${ Constants . specFileTypes . join ( "|" ) } )` ;
956
958
let ignoreFiles = args . exclude || bsConfig . run_settings . exclude ;
957
959
let files = glob . sync ( globSearchPattern , { cwd : bsConfig . run_settings . cypressProjectDir , matchBase : true , ignore : ignoreFiles } ) ;
@@ -1109,18 +1111,26 @@ exports.readBsConfigJSON = (bsConfigPath) => {
1109
1111
}
1110
1112
}
1111
1113
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
+ }
1122
1132
}
1123
- return cypressJSON ;
1133
+ return cypressConfigFile ;
1124
1134
}
1125
1135
1126
1136
exports . setCLIMode = ( bsConfig , args ) => {
@@ -1254,13 +1264,13 @@ exports.fetchZipSize = (fileName) => {
1254
1264
}
1255
1265
}
1256
1266
1257
- exports . getVideoConfig = ( cypressJson ) => {
1267
+ exports . getVideoConfig = ( cypressConfig ) => {
1258
1268
let conf = {
1259
1269
video : true ,
1260
1270
videoUploadOnPasses : true
1261
1271
}
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 ;
1264
1274
1265
1275
logger . debug ( `Setting video = ${ conf . video } ` ) ;
1266
1276
logger . debug ( `Setting videoUploadOnPasses = ${ conf . videoUploadOnPasses } ` ) ;
0 commit comments