11const logger = require ( "./logger" ) . winstonLogger ,
2- Constants = require ( "./constants" ) ;
2+ Constants = require ( "./constants" ) ,
3+ Util = require ( "./util" ) ;
34
45const caps = ( bsConfig , zip ) => {
56 return new Promise ( function ( resolve , reject ) {
@@ -61,7 +62,7 @@ const caps = (bsConfig, zip) => {
6162 } )
6263}
6364
64- const validate = ( bsConfig ) => {
65+ const validate = ( bsConfig , args ) => {
6566 return new Promise ( function ( resolve , reject ) {
6667 if ( ! bsConfig ) reject ( Constants . validationMessages . EMPTY_BROWSERSTACK_JSON ) ;
6768
@@ -71,7 +72,15 @@ const validate = (bsConfig) => {
7172
7273 if ( ! bsConfig . run_settings ) reject ( Constants . validationMessages . EMPTY_RUN_SETTINGS ) ;
7374
74- if ( ! bsConfig . run_settings . cypress_proj_dir ) reject ( Constants . validationMessages . EMPTY_SPEC_FILES ) ;
75+ if ( ! bsConfig . run_settings . cypress_proj_dir ) reject ( Constants . validationMessages . EMPTY_SPEC_FILES ) ;
76+
77+ // validate parallels specified in browserstack.json if parallels are not specified via arguments
78+ if ( Util . isUndefined ( args . parallels ) && ! Util . isParallelValid ( bsConfig . run_settings . parallels ) ) {
79+ reject ( Constants . validationMessages . INVALID_PARALLES_CONFIGURATION ) ;
80+ }
81+ // if parallels specified via arguments validate both parallels specifed in browserstack.json and parallels specified in arguments
82+ if ( ! Util . isUndefined ( args . parallels ) && ! Util . isParallelValid ( args . parallels ) ) reject ( Constants . validationMessages . INVALID_PARALLES_CONFIGURATION ) ;
83+
7584
7685 resolve ( Constants . validationMessages . VALIDATED ) ;
7786 } ) ;
0 commit comments