11const Gherkin = require ( '@cucumber/gherkin' )
22const Messages = require ( '@cucumber/messages' )
3- const { Context, Suite, Test } = require ( 'mocha' )
3+ const { Context, Suite } = require ( 'mocha' )
44const debug = require ( 'debug' ) ( 'codeceptjs:bdd' )
55
6+ const { enhanceMochaSuite } = require ( './suite' )
7+ const { createTest } = require ( './test' )
68const { matchStep } = require ( './bdd' )
79const event = require ( '../event' )
810const scenario = require ( './scenario' )
@@ -28,6 +30,7 @@ module.exports = (text, file) => {
2830 throw new Error ( `No 'Features' available in Gherkin '${ file } ' provided!` )
2931 }
3032 const suite = new Suite ( ast . feature . name , new Context ( ) )
33+ enhanceMochaSuite ( suite )
3134 const tags = ast . feature . tags . map ( t => t . name )
3235 suite . title = `${ suite . title } ${ tags . join ( ' ' ) } ` . trim ( )
3336 suite . tags = tags || [ ]
@@ -130,10 +133,10 @@ module.exports = (text, file) => {
130133 }
131134 }
132135
133- const test = new Test ( title , async ( ) => runSteps ( addExampleInTable ( exampleSteps , current ) ) )
136+ const test = createTest ( title , async ( ) => runSteps ( addExampleInTable ( exampleSteps , current ) ) )
137+ test . addToSuite ( suite )
134138 test . tags = suite . tags . concat ( tags )
135139 test . file = file
136- suite . addTest ( scenario . test ( test ) )
137140 }
138141 }
139142 continue
@@ -142,10 +145,10 @@ module.exports = (text, file) => {
142145 if ( child . scenario ) {
143146 const tags = child . scenario . tags . map ( t => t . name )
144147 const title = `${ child . scenario . name } ${ tags . join ( ' ' ) } ` . trim ( )
145- const test = new Test ( title , async ( ) => runSteps ( child . scenario . steps ) )
148+ const test = createTest ( title , async ( ) => runSteps ( child . scenario . steps ) )
149+ test . addToSuite ( suite )
146150 test . tags = suite . tags . concat ( tags )
147151 test . file = file
148- suite . addTest ( scenario . test ( test ) )
149152 }
150153 }
151154
0 commit comments