@@ -627,6 +627,58 @@ describe("config options", () => {
627627 } ) ;
628628 } ) ;
629629
630+ describe ( "hooks beforeAll/afterAll" , ( ) => {
631+ it ( "should throw error if beforeAll is not a null or function" , ( ) => {
632+ const readConfig = { beforeAll : "String" } ;
633+
634+ Config . read . returns ( readConfig ) ;
635+
636+ assert . throws ( ( ) => createConfig ( ) , Error , '"beforeAll" must be a function' ) ;
637+ } ) ;
638+
639+ it ( "should set default beforeAll option if it does not set in config file" , ( ) => {
640+ const config = createConfig ( ) ;
641+
642+ assert . equal ( config . beforeAll , defaults . beforeAll ) ;
643+ } ) ;
644+
645+ it ( "should override beforeAll option" , ( ) => {
646+ const newFunc = ( ) => { } ;
647+ const readConfig = { beforeAll : newFunc } ;
648+
649+ Config . read . returns ( readConfig ) ;
650+
651+ const config = createConfig ( ) ;
652+
653+ assert . deepEqual ( config . beforeAll , newFunc ) ;
654+ } ) ;
655+
656+ it ( "should throw error if afterAll is not a null or function" , ( ) => {
657+ const readConfig = { afterAll : "String" } ;
658+
659+ Config . read . returns ( readConfig ) ;
660+
661+ assert . throws ( ( ) => createConfig ( ) , Error , '"afterAll" must be a function' ) ;
662+ } ) ;
663+
664+ it ( "should set default afterAll option if it does not set in config file" , ( ) => {
665+ const config = createConfig ( ) ;
666+
667+ assert . equal ( config . afterAll , defaults . afterAll ) ;
668+ } ) ;
669+
670+ it ( "should override afterAll option" , ( ) => {
671+ const newFunc = ( ) => { } ;
672+ const readConfig = { afterAll : newFunc } ;
673+
674+ Config . read . returns ( readConfig ) ;
675+
676+ const config = createConfig ( ) ;
677+
678+ assert . deepEqual ( config . afterAll , newFunc ) ;
679+ } ) ;
680+ } ) ;
681+
630682 describe ( "plugins" , ( ) => {
631683 it ( "should parse boolean value from environment" , ( ) => {
632684 const result = parse_ ( {
0 commit comments