@@ -18,7 +18,7 @@ import DataTable from "./data_table";
1818
1919import {
2020 assignRegistry ,
21- freeRegistry , getRegistry ,
21+ freeRegistry ,
2222 IHook ,
2323 MissingDefinitionError ,
2424 Registry ,
@@ -303,7 +303,6 @@ function createFeature(context: CompositionContext, feature: messages.Feature) {
303303 describe ( feature . name || "<unamed feature>" , ( ) => {
304304 before ( function ( ) {
305305 beforeHandler . call ( this , context ) ;
306- beforeAllHandler . call ( this , context ) ;
307306 } ) ;
308307
309308 beforeEach ( function ( ) {
@@ -770,39 +769,23 @@ function shouldSkipPickle(testFilter: Node, pickle: messages.Pickle) {
770769 return ! testFilter . evaluate ( tags ) || tags . includes ( "@skip" ) ;
771770}
772771
773- function beforeHandler ( context : CompositionContext ) {
772+ function beforeHandler ( this : Mocha . Context , context : CompositionContext ) {
774773 if ( ! retrieveInternalSuiteProperties ( ) ?. isEventHandlersAttached ) {
775774 fail (
776775 "Missing preprocessor event handlers (this usally means you've not invoked `addCucumberPreprocessorPlugin()` or not returned the config object in `setupNodeEvents()`)"
777776 ) ;
778777 }
779-
780- taskSpecEnvelopes ( context ) ;
781- }
782-
783- function beforeAllHandler ( this : Mocha . Context , context : CompositionContext ) {
778+ // Handle BeforeAll hook
784779 const { registry } = context ;
785- let beforeAllHooks = registry . resolveBeforeAllHooks ( ) ;
786- for ( const beforeAllHook of beforeAllHooks ) {
787- if ( beforeAllHook ) {
788- const hook = beforeAllHook ;
789- cy . then ( ( ) => {
790- const start = createTimestamp ( ) ;
791- return cy . wrap ( start , { log : false } ) ;
792- } )
793- . then ( ( start ) => {
794- runStepWithLogGroup ( {
795- fn : ( ) => registry . runHook ( this , hook ) ,
796- keyword : "BeforeAll"
797- } ) ;
798-
799- return cy . wrap ( start , { log : false } ) ;
800- } )
801- . then ( ( start ) => {
802- const end = createTimestamp ( ) ;
803- } ) ;
804- }
805- }
780+ const beforeAllHooks = registry . resolveBeforeAllHooks ( ) ;
781+ for ( const beforeAllHook of beforeAllHooks ) {
782+ const hook = beforeAllHook ;
783+ runStepWithLogGroup ( {
784+ fn : ( ) => registry . runHook ( this , hook ) ,
785+ keyword : "BeforeAll" ,
786+ } ) ;
787+ }
788+ taskSpecEnvelopes ( context ) ;
806789}
807790
808791function beforeEachHandler ( context : CompositionContext ) {
@@ -1058,26 +1041,13 @@ function afterEachHandler(this: Mocha.Context, context: CompositionContext) {
10581041
10591042function afterAllHandler ( this : Mocha . Context , context : CompositionContext ) {
10601043 const { registry } = context ;
1061- let afterAllHooks = registry . resolveAfterAllHooks ( ) ;
1062- for ( const afterAllHook of afterAllHooks ) {
1063- if ( afterAllHook ) {
1064- const hook = afterAllHook ;
1065- cy . then ( ( ) => {
1066- const start = createTimestamp ( ) ;
1067- return cy . wrap ( start , { log : false } ) ;
1068- } )
1069- . then ( ( start ) => {
1070- runStepWithLogGroup ( {
1071- fn : ( ) => registry . runHook ( this , hook ) ,
1072- keyword : "AfterAll"
1073- } ) ;
1074-
1075- return cy . wrap ( start , { log : false } ) ;
1076- } )
1077- . then ( ( start ) => {
1078- const end = createTimestamp ( ) ;
1079- } ) ;
1080- }
1044+ const afterAllHooks = registry . resolveAfterAllHooks ( ) ;
1045+ for ( const afterAllHook of afterAllHooks ) {
1046+ const hook = afterAllHook ;
1047+ runStepWithLogGroup ( {
1048+ fn : ( ) => registry . runHook ( this , hook ) ,
1049+ keyword : "AfterAll" ,
1050+ } ) ;
10811051 }
10821052}
10831053export default function createTests (
0 commit comments