11const fs = require ( "fs" ) ;
22const semver = require ( "semver" ) ;
3- const semverCompare = require ( ' semver/functions/compare' ) ;
3+ const semverCompare = require ( " semver/functions/compare" ) ;
44
55const constants = require ( "./constants.js" ) ;
66module . exports = validate_config = function ( lt_config , validation_configs ) {
@@ -51,7 +51,6 @@ module.exports = validate_config = function (lt_config, validation_configs) {
5151 reject ( "Error!! Parallels value not correct" ) ;
5252 }
5353
54-
5554 //Validate if package.json is having the cypress dependency
5655 var cypress_version ;
5756 if ( ! fs . existsSync ( "package.json" ) ) {
@@ -123,13 +122,11 @@ module.exports = validate_config = function (lt_config, validation_configs) {
123122 }
124123
125124 //validate if cypress config file is passed and exists
126-
127125 cypress_version = semver . coerce ( cypress_version ) . version ;
128126 // validate cypress.json only in case of cypress<10
129127 if (
130128 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" ]
133130 ) {
134131 if ( ! fs . existsSync ( lt_config [ "run_settings" ] [ "cypress_config_file" ] ) ) {
135132 reject ( "Error!! Cypress Config File does not exist" ) ;
@@ -146,9 +143,15 @@ module.exports = validate_config = function (lt_config, validation_configs) {
146143 reject ( "Error!! Cypress Config File does not has correct json" ) ;
147144 }
148145 }
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+ ) ;
149153 }
150154
151-
152155 if (
153156 lt_config [ "run_settings" ] [ "ignore_files" ] &&
154157 lt_config [ "run_settings" ] [ "ignore_files" ] . length > 0
@@ -238,9 +241,14 @@ module.exports = validate_config = function (lt_config, validation_configs) {
238241 reject (
239242 "Error!! Reporter JSON File has no keys, either remove Key reporter_config_file from lambdatest config or pass some options"
240243 ) ;
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+ ) ;
244252 }
245253 }
246254 } catch {
@@ -250,8 +258,10 @@ module.exports = validate_config = function (lt_config, validation_configs) {
250258 reject ( "Error!! Reporter JSON File does not have correct json" ) ;
251259 }
252260 }
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+ ) ;
255265 }
256266
257267 if (
@@ -342,17 +352,19 @@ module.exports = validate_config = function (lt_config, validation_configs) {
342352 if ( "sys_envs" in lt_config [ "run_settings" ] ) {
343353 let sys_envs = lt_config [ "run_settings" ] [ "sys_envs" ] ;
344354 let envValue ;
345- Object . keys ( sys_envs ) . forEach ( function ( envKey ) {
355+ Object . keys ( sys_envs ) . forEach ( function ( envKey ) {
346356 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+ ) ;
349361 }
350- if ( envValue == undefined || envValue === "" ) {
362+ if ( envValue == undefined || envValue === "" ) {
351363 reject ( "Value of environment variable cannot be left blank" ) ;
352364 }
353- } )
354-
365+ } ) ;
355366 }
367+
356368 resolve ( cypress_version ) ;
357369 } ) ;
358370} ;
0 commit comments