1
1
const fs = require ( "fs" ) ;
2
2
const semver = require ( "semver" ) ;
3
- const semverCompare = require ( ' semver/functions/compare' ) ;
3
+ const semverCompare = require ( " semver/functions/compare" ) ;
4
4
5
5
const constants = require ( "./constants.js" ) ;
6
6
module . exports = validate_config = function ( lt_config , validation_configs ) {
@@ -51,7 +51,6 @@ module.exports = validate_config = function (lt_config, validation_configs) {
51
51
reject ( "Error!! Parallels value not correct" ) ;
52
52
}
53
53
54
-
55
54
//Validate if package.json is having the cypress dependency
56
55
var cypress_version ;
57
56
if ( ! fs . existsSync ( "package.json" ) ) {
@@ -123,13 +122,11 @@ module.exports = validate_config = function (lt_config, validation_configs) {
123
122
}
124
123
125
124
//validate if cypress config file is passed and exists
126
-
127
125
cypress_version = semver . coerce ( cypress_version ) . version ;
128
126
// validate cypress.json only in case of cypress<10
129
127
if (
130
128
semverCompare ( cypress_version , "10.0.0" ) == - 1 &&
131
- lt_config [ "run_settings" ] [ "cypress_config_file" ] &&
132
- lt_config [ "run_settings" ] [ "cypress_config_file" ] != ""
129
+ lt_config [ "run_settings" ] [ "cypress_config_file" ]
133
130
) {
134
131
if ( ! fs . existsSync ( lt_config [ "run_settings" ] [ "cypress_config_file" ] ) ) {
135
132
reject ( "Error!! Cypress Config File does not exist" ) ;
@@ -146,9 +143,15 @@ module.exports = validate_config = function (lt_config, validation_configs) {
146
143
reject ( "Error!! Cypress Config File does not has correct json" ) ;
147
144
}
148
145
}
146
+ } else if (
147
+ semverCompare ( cypress_version , "10.0.0" ) >= 0 &&
148
+ lt_config [ "run_settings" ] [ "cypress_config_file" ]
149
+ ) {
150
+ reject (
151
+ 'Error!! --ccf flag and cypress_config_file is not cupported with cypress>=10,use \n --cy="--config-file <file path>"'
152
+ ) ;
149
153
}
150
154
151
-
152
155
if (
153
156
lt_config [ "run_settings" ] [ "ignore_files" ] &&
154
157
lt_config [ "run_settings" ] [ "ignore_files" ] . length > 0
@@ -238,9 +241,14 @@ module.exports = validate_config = function (lt_config, validation_configs) {
238
241
reject (
239
242
"Error!! Reporter JSON File has no keys, either remove Key reporter_config_file from lambdatest config or pass some options"
240
243
) ;
241
- } else if ( reporter_config . reporterEnabled && reporter_config . reporterEnabled != "" ) {
242
- if ( ! reporter_config . reporterEnabled . includes ( "mochawesome" ) ) {
243
- console . log ( "Warning!! mochawesome reporter config not present. Command log may not be visible on dashboard" ) ;
244
+ } else if (
245
+ reporter_config . reporterEnabled &&
246
+ reporter_config . reporterEnabled != ""
247
+ ) {
248
+ if ( ! reporter_config . reporterEnabled . includes ( "mochawesome" ) ) {
249
+ console . log (
250
+ "Warning!! mochawesome reporter config not present. Command log may not be visible on dashboard"
251
+ ) ;
244
252
}
245
253
}
246
254
} catch {
@@ -250,8 +258,10 @@ module.exports = validate_config = function (lt_config, validation_configs) {
250
258
reject ( "Error!! Reporter JSON File does not have correct json" ) ;
251
259
}
252
260
}
253
- } else {
254
- console . log ( "Warning!! Value of reporter_config_file parameter missing. Proceeding with default reporter config" )
261
+ } else {
262
+ console . log (
263
+ "Warning!! Value of reporter_config_file parameter missing. Proceeding with default reporter config"
264
+ ) ;
255
265
}
256
266
257
267
if (
@@ -342,17 +352,19 @@ module.exports = validate_config = function (lt_config, validation_configs) {
342
352
if ( "sys_envs" in lt_config [ "run_settings" ] ) {
343
353
let sys_envs = lt_config [ "run_settings" ] [ "sys_envs" ] ;
344
354
let envValue ;
345
- Object . keys ( sys_envs ) . forEach ( function ( envKey ) {
355
+ Object . keys ( sys_envs ) . forEach ( function ( envKey ) {
346
356
envValue = sys_envs [ envKey ] ;
347
- if ( envKey && ! constants . WHITELISTED_ENV_VARS . includes ( envKey ) ) {
348
- reject ( `Usage of unwanted environment variable detected. Allowed variables are - ${ constants . WHITELISTED_ENV_VARS } ` ) ;
357
+ if ( envKey && ! constants . WHITELISTED_ENV_VARS . includes ( envKey ) ) {
358
+ reject (
359
+ `Usage of unwanted environment variable detected. Allowed variables are - ${ constants . WHITELISTED_ENV_VARS } `
360
+ ) ;
349
361
}
350
- if ( envValue == undefined || envValue === "" ) {
362
+ if ( envValue == undefined || envValue === "" ) {
351
363
reject ( "Value of environment variable cannot be left blank" ) ;
352
364
}
353
- } )
354
-
365
+ } ) ;
355
366
}
367
+
356
368
resolve ( cypress_version ) ;
357
369
} ) ;
358
370
} ;
0 commit comments