@@ -2721,6 +2721,10 @@ describe('utils', () => {
2721
2721
expect ( utils . sanitizeSpecsPattern ( 'pattern3' ) ) . to . eq ( 'pattern3' ) ;
2722
2722
} ) ;
2723
2723
2724
+ it ( 'should not wrap pattern around {} when input already has {}' , ( ) => {
2725
+ expect ( utils . sanitizeSpecsPattern ( 'pattern/{folderA,folderB}/*.spec.ts' ) ) . to . eq ( 'pattern/{folderA,folderB}/*.spec.ts' ) ;
2726
+ } ) ;
2727
+
2724
2728
it ( 'should return undefined when --spec is undefined' , ( ) => {
2725
2729
expect ( utils . sanitizeSpecsPattern ( undefined ) ) . to . eq ( undefined ) ;
2726
2730
} ) ;
@@ -3094,56 +3098,133 @@ describe('utils', () => {
3094
3098
describe ( 'setEnforceSettingsConfig' , ( ) => {
3095
3099
it ( 'the video config should be assigned to bsconfig run_settings config' , ( ) => {
3096
3100
let bsConfig = {
3097
- run_settings : { video_config : { video :true , videoUploadOnPasses :true } } ,
3101
+ run_settings : {
3102
+ video_config : { video :true , videoUploadOnPasses :true } ,
3103
+ cypressProjectDir : 'cypressProjectDir' ,
3104
+ } ,
3098
3105
} ;
3099
3106
let args = {
3100
3107
config : 'video=true,videoUploadOnPasses=true'
3101
3108
}
3102
- utils . setEnforceSettingsConfig ( bsConfig ) ;
3109
+ utils . setEnforceSettingsConfig ( bsConfig , args ) ;
3103
3110
expect ( args . config ) . to . be . eql ( bsConfig . run_settings . config ) ;
3104
3111
} ) ;
3105
- it ( 'the specPattern config should be assigned as strings for single string to bsconfig run_settings config' , ( ) => {
3112
+ it ( 'the specPattern config should be assigned as array for single spec string to bsconfig run_settings config' , ( ) => {
3106
3113
let bsConfig = {
3107
- run_settings : { specs : 'somerandomspecs' , cypressTestSuiteType : 'CYPRESS_V10_AND_ABOVE_TYPE' } ,
3114
+ run_settings : {
3115
+ specs : 'somerandomspecs' ,
3116
+ cypressTestSuiteType : 'CYPRESS_V10_AND_ABOVE_TYPE' ,
3117
+ cypressProjectDir : 'cypressProjectDir' ,
3118
+ } ,
3108
3119
} ;
3109
3120
let args = {
3121
+ exclude : "" ,
3110
3122
config : 'video=false,videoUploadOnPasses=false,specPattern=somerandomspecs'
3111
3123
}
3112
- utils . setEnforceSettingsConfig ( bsConfig ) ;
3124
+ utils . setEnforceSettingsConfig ( bsConfig , args ) ;
3113
3125
expect ( args . config ) . to . be . eql ( bsConfig . run_settings . config ) ;
3114
3126
} ) ;
3115
3127
it ( 'the specPattern config should be assigned as array for multiple spec strings to bsconfig run_settings config' , ( ) => {
3116
3128
let bsConfig = {
3117
- run_settings : { specs : 'somerandomspecs1,somerandomspecs2' , cypressTestSuiteType : 'CYPRESS_V10_AND_ABOVE_TYPE' } ,
3129
+ run_settings : {
3130
+ specs : 'somerandomspecs1,somerandomspecs2' ,
3131
+ cypressTestSuiteType : 'CYPRESS_V10_AND_ABOVE_TYPE' ,
3132
+ cypressProjectDir : 'cypressProjectDir' ,
3133
+ } ,
3118
3134
} ;
3119
3135
let args = {
3136
+ exclude : "" ,
3120
3137
config : 'video=false,videoUploadOnPasses=false,specPattern=["somerandomspecs1","somerandomspecs2"]'
3121
3138
}
3122
- utils . setEnforceSettingsConfig ( bsConfig ) ;
3139
+ utils . setEnforceSettingsConfig ( bsConfig , args ) ;
3140
+ expect ( args . config ) . to . be . eql ( bsConfig . run_settings . config ) ;
3141
+ } ) ;
3142
+ it ( 'the specPattern config should not be assigned just on the basis of "," as array for single spec string to bsconfig run_settings config' , ( ) => {
3143
+ let bsConfig = {
3144
+ run_settings : {
3145
+ specs : 'folders/{sample1,sample2}/somerandomspecs' ,
3146
+ cypressTestSuiteType : 'CYPRESS_V10_AND_ABOVE_TYPE' ,
3147
+ cypressProjectDir : 'cypressProjectDir' ,
3148
+ } ,
3149
+ } ;
3150
+ let args = {
3151
+ exclude : "" ,
3152
+ config : 'video=false,videoUploadOnPasses=false,specPattern=["folders/{sample1,sample2}/somerandomspecs"]'
3153
+ }
3154
+ utils . setEnforceSettingsConfig ( bsConfig , args ) ;
3155
+ expect ( args . config ) . to . be . eql ( bsConfig . run_settings . config ) ;
3156
+ } ) ;
3157
+ it ( 'the specPattern config should not be assigned just on the basis of "," as array for multiple spec strings to bsconfig run_settings config' , ( ) => {
3158
+ let bsConfig = {
3159
+ run_settings : {
3160
+ specs : 'folders/{sample1,sample2}/somerandomspecs,folders2/sample3/somerandomspecs2' ,
3161
+ cypressTestSuiteType : 'CYPRESS_V10_AND_ABOVE_TYPE' ,
3162
+ cypressProjectDir : 'cypressProjectDir' ,
3163
+ } ,
3164
+ } ;
3165
+ let args = {
3166
+ exclude : "" ,
3167
+ config : 'video=false,videoUploadOnPasses=false,specPattern=["folders/{sample1,sample2}/somerandomspecs","folders2/sample3/somerandomspecs2"]'
3168
+ }
3169
+ utils . setEnforceSettingsConfig ( bsConfig , args ) ;
3123
3170
expect ( args . config ) . to . be . eql ( bsConfig . run_settings . config ) ;
3124
3171
} ) ;
3125
3172
it ( 'the testFiles config should be assigned to bsconfig run_settings config' , ( ) => {
3126
3173
let bsConfig = {
3127
3174
run_settings : { specs : 'somerandomspecs' , cypressTestSuiteType : 'CYPRESS_V9_AND_OLDER_TYPE' } ,
3128
3175
} ;
3129
3176
let args = {
3130
- config : 'video=false,videoUploadOnPasses=false'
3177
+ config : 'video=false,videoUploadOnPasses=false' ,
3178
+ cypressProjectDir : 'cypressProjectDir' ,
3131
3179
}
3132
- utils . setEnforceSettingsConfig ( bsConfig ) ;
3180
+ utils . setEnforceSettingsConfig ( bsConfig , args ) ;
3133
3181
expect ( args . config ) . to . be . eql ( bsConfig . run_settings . config ) ;
3134
3182
} ) ;
3135
3183
it ( 'the baseUrl config should be assigned to bsconfig run_settings config' , ( ) => {
3136
3184
let bsConfig = {
3137
- run_settings : { baseUrl : 'http://localhost:8080' } ,
3185
+ run_settings : {
3186
+ baseUrl : 'http://localhost:8080' ,
3187
+ cypressProjectDir : 'cypressProjectDir' ,
3188
+ } ,
3138
3189
} ;
3139
3190
let args = {
3140
3191
config : 'video=false,videoUploadOnPasses=false,baseUrl=http://localhost:8080'
3141
3192
}
3142
- utils . setEnforceSettingsConfig ( bsConfig ) ;
3193
+ utils . setEnforceSettingsConfig ( bsConfig , args ) ;
3143
3194
expect ( args . config ) . to . be . eql ( bsConfig . run_settings . config ) ;
3144
3195
} ) ;
3145
3196
} ) ;
3146
3197
3198
+ describe ( 'splitStringByCharButIgnoreIfWithinARange' , ( ) => {
3199
+ it ( 'should return null if string is not provided' , ( ) => {
3200
+ expect ( utils . splitStringByCharButIgnoreIfWithinARange ( ) ) . to . be . eql ( null ) ;
3201
+ } ) ;
3202
+
3203
+ it ( 'should return null if splitChar is not provided' , ( ) => {
3204
+ expect ( utils . splitStringByCharButIgnoreIfWithinARange ( "some" ) ) . to . be . eql ( null ) ;
3205
+ } ) ;
3206
+
3207
+ it ( 'should return splitted string even if leftLimiter and rightLimiter is not provided' , ( ) => {
3208
+ expect ( utils . splitStringByCharButIgnoreIfWithinARange ( "some,random,text" , "," ) ) . to . be . eql ( [ "some" , "random" , "text" ] ) ;
3209
+ } ) ;
3210
+
3211
+ it ( 'should return splitted string even if leftLimiter is provided but rightLimiter is not provided' , ( ) => {
3212
+ expect ( utils . splitStringByCharButIgnoreIfWithinARange ( "some,random,{text,here},and,here" , "," , "{" ) ) . to . be . eql ( [ "some" , "random" , "{text" , "here}" , "and" , "here" ] ) ;
3213
+ } ) ;
3214
+
3215
+ it ( 'should return splitted string even if leftLimiter is not provided but rightLimiter is provided' , ( ) => {
3216
+ expect ( utils . splitStringByCharButIgnoreIfWithinARange ( "some,random,{text,here},and,here" , "," , null , "}" ) ) . to . be . eql ( [ "some" , "random" , "{text" , "here}" , "and" , "here" ] ) ;
3217
+ } ) ;
3218
+
3219
+ it ( 'should return splitted string and ignore splitting if splitChar is withing the leftLimiter and rightLimiter' , ( ) => {
3220
+ expect ( utils . splitStringByCharButIgnoreIfWithinARange ( "some,random,{text,here},and,here" , "," , "{" , "}" ) ) . to . be . eql ( [ "some" , "random" , "{text,here}" , "and" , "here" ] ) ;
3221
+ } ) ;
3222
+
3223
+ it ( 'should return splitted string and ignore splitting if splitChar is withing the leftLimiter and rightLimiter' , ( ) => {
3224
+ expect ( utils . splitStringByCharButIgnoreIfWithinARange ( "some,random,{text,here}" , "," , "{" , "}" ) ) . to . be . eql ( [ "some" , "random" , "{text,here}" ] ) ;
3225
+ } ) ;
3226
+ } ) ;
3227
+
3147
3228
describe ( 'generateUniqueHash' , ( ) => {
3148
3229
beforeEach ( ( ) => {
3149
3230
let interfaceList = {
0 commit comments