@@ -504,7 +504,7 @@ describe("capabilityHelper.js", () => {
504504 it ( "validate bsConfig" , ( ) => {
505505 let bsConfig = undefined ;
506506 return capabilityHelper
507- . validate ( bsConfig , { parallels : undefined } )
507+ . validate ( bsConfig , { parallels : undefined } )
508508 . then ( function ( data ) {
509509 chai . assert . fail ( "Promise error" ) ;
510510 } )
@@ -516,7 +516,7 @@ describe("capabilityHelper.js", () => {
516516 it ( "validate bsConfig.auth" , ( ) => {
517517 bsConfig = { } ;
518518 return capabilityHelper
519- . validate ( bsConfig , { parallels : undefined } )
519+ . validate ( bsConfig , { parallels : undefined } )
520520 . then ( function ( data ) {
521521 chai . assert . fail ( "Promise error" ) ;
522522 } )
@@ -536,7 +536,7 @@ describe("capabilityHelper.js", () => {
536536 }
537537 } ;
538538 return capabilityHelper
539- . validate ( bsConfig , { parallels : undefined } )
539+ . validate ( bsConfig , { parallels : undefined } )
540540 . then ( function ( data ) {
541541 chai . assert . fail ( "Promise error" ) ;
542542 } )
@@ -554,7 +554,7 @@ describe("capabilityHelper.js", () => {
554554 browsers : [ ] ,
555555 } ;
556556 return capabilityHelper
557- . validate ( bsConfig , { parallels : undefined } )
557+ . validate ( bsConfig , { parallels : undefined } )
558558 . then ( function ( data ) {
559559 chai . assert . fail ( "Promise error" ) ;
560560 } )
@@ -578,7 +578,7 @@ describe("capabilityHelper.js", () => {
578578 ] ,
579579 } ;
580580 return capabilityHelper
581- . validate ( bsConfig , { parallels : undefined } )
581+ . validate ( bsConfig , { parallels : undefined } )
582582 . then ( function ( data ) {
583583 chai . assert . fail ( "Promise error" ) ;
584584 } )
@@ -604,7 +604,7 @@ describe("capabilityHelper.js", () => {
604604 } ;
605605
606606 return capabilityHelper
607- . validate ( bsConfig , { parallels : undefined } )
607+ . validate ( bsConfig , { parallels : undefined } )
608608 . then ( function ( data ) {
609609 chai . assert . fail ( "Promise error" ) ;
610610 } )
@@ -631,13 +631,107 @@ describe("capabilityHelper.js", () => {
631631 } ,
632632 } ;
633633 capabilityHelper
634- . validate ( bsConfig , { parallels : undefined } )
634+ . validate ( bsConfig , { parallels : undefined } )
635635 . then ( function ( data ) {
636636 chai . assert . equal ( data , Constants . validationMessages . VALIDATED ) ;
637637 } )
638638 . catch ( ( error ) => {
639639 chai . assert . fail ( "Promise error" ) ;
640640 } ) ;
641641 } ) ;
642+ describe ( "validate cypress.json" , ( ) => {
643+ beforeEach ( ( ) => {
644+ bsConfig = {
645+ auth : { } ,
646+ browsers : [
647+ {
648+ browser : "chrome" ,
649+ os : "Windows 10" ,
650+ versions : [ "78" , "77" ] ,
651+ } ,
652+ ] ,
653+ run_settings : {
654+ cypress_proj_dir : "random path"
655+ } ,
656+ } ;
657+ } ) ;
658+ it ( "validate cypress json is present" , ( ) => {
659+ //Stub for cypress json validation
660+ sinon . stub ( fs , 'existsSync' ) . returns ( false ) ;
661+
662+ return capabilityHelper
663+ . validate ( bsConfig , { parallels : undefined } )
664+ . then ( function ( data ) {
665+ chai . assert . fail ( "Promise error" ) ;
666+ } )
667+ . catch ( ( error ) => {
668+ chai . assert . equal (
669+ error ,
670+ Constants . validationMessages . CYPRESS_JSON_NOT_FOUND + "random path"
671+ ) ;
672+ fs . existsSync . restore ( ) ;
673+ } ) ;
674+ } ) ;
675+
676+ it ( "validate cypress json is valid" , ( ) => {
677+ //Stub for cypress json validation
678+ sinon . stub ( fs , 'existsSync' ) . returns ( true ) ;
679+ sinon . stub ( fs , 'readFileSync' ) . returns ( "{invalid}" ) ;
680+
681+ return capabilityHelper
682+ . validate ( bsConfig , { parallels : undefined } )
683+ . then ( function ( data ) {
684+ chai . assert . fail ( "Promise error" ) ;
685+ } )
686+ . catch ( ( error ) => {
687+ chai . assert . equal (
688+ error ,
689+ Constants . validationMessages . INVALID_CYPRESS_JSON
690+ ) ;
691+ fs . existsSync . restore ( ) ;
692+ fs . readFileSync . restore ( ) ;
693+ } ) ;
694+ } ) ;
695+
696+ it ( "validate baseUrl is set to localhost and local is not set to true" , ( ) => {
697+ //Stub for cypress json validation
698+ sinon . stub ( fs , 'existsSync' ) . returns ( true ) ;
699+ sinon . stub ( fs , 'readFileSync' ) . returns ( '{ "baseUrl": "http://localhost:3000"}' ) ;
700+
701+ return capabilityHelper
702+ . validate ( bsConfig , { parallels : undefined } )
703+ . then ( function ( data ) {
704+ chai . assert . fail ( "Promise error" ) ;
705+ } )
706+ . catch ( ( error ) => {
707+ chai . assert . equal (
708+ error ,
709+ Constants . validationMessages . LOCAL_NOT_SET
710+ ) ;
711+ fs . existsSync . restore ( ) ;
712+ fs . readFileSync . restore ( ) ;
713+ } ) ;
714+ } ) ;
715+
716+ it ( "validate integrationFolder is set and is accessible from cypress_proj_dir" , ( ) => {
717+ //Stub for cypress json validation
718+ sinon . stub ( fs , 'existsSync' ) . returns ( true ) ;
719+ sinon . stub ( fs , 'readFileSync' ) . returns ( '{ "integrationFolder": "/absolute/path"}' ) ;
720+
721+ return capabilityHelper
722+ . validate ( bsConfig , { parallels : undefined } )
723+ . then ( function ( data ) {
724+ chai . assert . fail ( "Promise error" ) ;
725+ } )
726+ . catch ( ( error ) => {
727+ chai . assert . equal (
728+ error ,
729+ Constants . validationMessages . INCORRECT_DIRECTORY_STRUCTURE
730+ ) ;
731+ fs . existsSync . restore ( ) ;
732+ fs . readFileSync . restore ( ) ;
733+ } ) ;
734+ } ) ;
735+ } ) ;
642736 } ) ;
643737} ) ;
0 commit comments