@@ -15,15 +15,13 @@ function attach(this: { test: any }, body: any, details: any) {
15
15
const fixture = new supportCodeLibrary . World ( { } ) ;
16
16
const test = fixture . test ;
17
17
18
+ for ( const beforeAllHook of supportCodeLibrary . beforeTestRunHookDefinitions ) {
19
+ test . beforeAll ( ( ) => beforeAllHook . code . apply ( { } ) ) ;
20
+ }
21
+
18
22
for ( const feature of features ) {
19
23
const tests = feature . tests ;
20
24
test . describe ( feature . feature as string , async ( ) => {
21
- for ( const beforeAllHook of supportCodeLibrary . beforeTestRunHookDefinitions ) {
22
- test . beforeAll ( async ( ) => {
23
- await beforeAllHook . code . apply ( { } ) ;
24
- } ) ;
25
- }
26
-
27
25
const world = new supportCodeLibrary . World ( {
28
26
log,
29
27
attach,
@@ -39,28 +37,26 @@ for (const feature of features) {
39
37
for ( const beforeHook of supportCodeLibrary . beforeTestCaseHookDefinitions ) {
40
38
if ( beforeHook . appliesToTestCase ( testCase ) ) {
41
39
const hookName = beforeHook . name ?? 'Before' ;
42
- await test . step ( hookName , async ( ) => {
43
- await beforeHook . code . apply ( world , [ {
44
- pickle : testCase
45
- } ] ) ;
46
- } ) ;
40
+ await test . step ( hookName , ( ) => beforeHook . code . apply ( world , [ {
41
+ pickle : testCase
42
+ } ] ) ) ;
47
43
}
48
44
}
49
45
for ( const pickleStep of testCase . steps ) {
50
46
await test . step ( pickleStep . text , async ( ) => {
51
47
for ( const beforeStep of supportCodeLibrary . beforeTestStepHookDefinitions ) {
52
48
if ( beforeStep . appliesToTestCase ( testCase ) ) {
53
- await beforeStep . code . apply ( world , [ {
49
+ await test . step ( 'Before Step' , ( ) => beforeStep . code . apply ( world , [ {
54
50
pickle : testCase ,
55
51
pickleStep
56
- } ] ) ;
52
+ } ] ) ) ;
57
53
}
58
54
}
59
55
const steps = supportCodeLibrary . stepDefinitions
60
56
. filter ( stepDefinition => stepDefinition . matchesStepName ( pickleStep . text ) ) ;
61
57
if ( steps . length === 0 ) throw new Error ( `Step '${ pickleStep . text } ' is not defined` ) ;
62
58
if ( steps . length > 1 ) throw new Error ( `'${ pickleStep . text } ' matches multiple step definitions` ) ;
63
- const [ step ] = steps ;
59
+ const [ step ] = steps ;
64
60
const { parameters} = await step . getInvocationParameters ( {
65
61
step : {
66
62
text : pickleStep . text ,
@@ -76,11 +72,11 @@ for (const feature of features) {
76
72
}
77
73
for ( const afterStep of supportCodeLibrary . afterTestStepHookDefinitions ) {
78
74
if ( afterStep . appliesToTestCase ( testCase ) ) {
79
- await afterStep . code . apply ( world , [ {
75
+ await test . step ( 'After Step' , ( ) => afterStep . code . apply ( world , [ {
80
76
pickle : testCase ,
81
77
pickleStep,
82
78
result
83
- } ] ) ;
79
+ } ] ) ) ;
84
80
}
85
81
}
86
82
if ( result . error ) throw result . error ;
@@ -89,19 +85,16 @@ for (const feature of features) {
89
85
for ( const afterHook of supportCodeLibrary . afterTestCaseHookDefinitions ) {
90
86
if ( afterHook . appliesToTestCase ( testCase ) ) {
91
87
const hookName = afterHook . name ?? 'After' ;
92
- await test . step ( hookName , async ( ) => {
93
- await afterHook . code . apply ( world , [ {
94
- pickle : testCase , result
95
- } ] ) ;
96
- } ) ;
88
+ await test . step ( hookName , ( ) => afterHook . code . apply ( world , [ {
89
+ pickle : testCase , result
90
+ } ] ) ) ;
97
91
}
98
92
}
99
93
} )
100
94
}
101
- for ( const afterAllHook of supportCodeLibrary . afterTestRunHookDefinitions ) {
102
- test . afterAll ( async function ( ) {
103
- await afterAllHook . code . apply ( { } ) ;
104
- } ) ;
105
- }
106
95
} ) ;
107
96
}
97
+
98
+ for ( const afterAllHook of supportCodeLibrary . afterTestRunHookDefinitions ) {
99
+ test . afterAll ( ( ) => afterAllHook . code . apply ( { } ) ) ;
100
+ }
0 commit comments