@@ -504,7 +504,7 @@ describe("capabilityHelper.js", () => {
504
504
it ( "validate bsConfig" , ( ) => {
505
505
let bsConfig = undefined ;
506
506
return capabilityHelper
507
- . validate ( bsConfig , { parallels : undefined } )
507
+ . validate ( bsConfig , { parallels : undefined } )
508
508
. then ( function ( data ) {
509
509
chai . assert . fail ( "Promise error" ) ;
510
510
} )
@@ -516,7 +516,7 @@ describe("capabilityHelper.js", () => {
516
516
it ( "validate bsConfig.auth" , ( ) => {
517
517
bsConfig = { } ;
518
518
return capabilityHelper
519
- . validate ( bsConfig , { parallels : undefined } )
519
+ . validate ( bsConfig , { parallels : undefined } )
520
520
. then ( function ( data ) {
521
521
chai . assert . fail ( "Promise error" ) ;
522
522
} )
@@ -536,7 +536,7 @@ describe("capabilityHelper.js", () => {
536
536
}
537
537
} ;
538
538
return capabilityHelper
539
- . validate ( bsConfig , { parallels : undefined } )
539
+ . validate ( bsConfig , { parallels : undefined } )
540
540
. then ( function ( data ) {
541
541
chai . assert . fail ( "Promise error" ) ;
542
542
} )
@@ -554,7 +554,7 @@ describe("capabilityHelper.js", () => {
554
554
browsers : [ ] ,
555
555
} ;
556
556
return capabilityHelper
557
- . validate ( bsConfig , { parallels : undefined } )
557
+ . validate ( bsConfig , { parallels : undefined } )
558
558
. then ( function ( data ) {
559
559
chai . assert . fail ( "Promise error" ) ;
560
560
} )
@@ -578,7 +578,7 @@ describe("capabilityHelper.js", () => {
578
578
] ,
579
579
} ;
580
580
return capabilityHelper
581
- . validate ( bsConfig , { parallels : undefined } )
581
+ . validate ( bsConfig , { parallels : undefined } )
582
582
. then ( function ( data ) {
583
583
chai . assert . fail ( "Promise error" ) ;
584
584
} )
@@ -604,7 +604,7 @@ describe("capabilityHelper.js", () => {
604
604
} ;
605
605
606
606
return capabilityHelper
607
- . validate ( bsConfig , { parallels : undefined } )
607
+ . validate ( bsConfig , { parallels : undefined } )
608
608
. then ( function ( data ) {
609
609
chai . assert . fail ( "Promise error" ) ;
610
610
} )
@@ -631,13 +631,107 @@ describe("capabilityHelper.js", () => {
631
631
} ,
632
632
} ;
633
633
capabilityHelper
634
- . validate ( bsConfig , { parallels : undefined } )
634
+ . validate ( bsConfig , { parallels : undefined } )
635
635
. then ( function ( data ) {
636
636
chai . assert . equal ( data , Constants . validationMessages . VALIDATED ) ;
637
637
} )
638
638
. catch ( ( error ) => {
639
639
chai . assert . fail ( "Promise error" ) ;
640
640
} ) ;
641
641
} ) ;
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
+ } ) ;
642
736
} ) ;
643
737
} ) ;
0 commit comments