11const glob = require ( 'glob' )
22const path = require ( 'path' )
3+ const debug = require ( 'debug' ) ( 'codeceptjs:container' )
34const { MetaStep } = require ( './step' )
45const { methodsOfObject, fileExists, isFunction, isAsyncFunction, installedLocally } = require ( './utils' )
56const Translation = require ( './translation' )
@@ -38,6 +39,7 @@ class Container {
3839 * @param {* } opts
3940 */
4041 static create ( config , opts ) {
42+ debug ( 'creating container' )
4143 asyncHelperPromise = Promise . resolve ( )
4244
4345 // dynamically create mocha instance
@@ -134,6 +136,7 @@ class Container {
134136 static append ( newContainer ) {
135137 const deepMerge = require ( './utils' ) . deepMerge
136138 container = deepMerge ( container , newContainer )
139+ debug ( 'appended' , JSON . stringify ( newContainer ) . slice ( 0 , 300 ) )
137140 }
138141
139142 /**
@@ -150,6 +153,7 @@ class Container {
150153 container . plugins = newPlugins || { }
151154 asyncHelperPromise = Promise . resolve ( )
152155 store . actor = null
156+ debug ( 'container cleared' )
153157 }
154158
155159 /**
@@ -216,6 +220,8 @@ function createHelpers(config) {
216220 throw new Error ( `Helper class from module '${ helperName } ' is not a class. Use CJS async module syntax.` )
217221 }
218222
223+ debug ( `helper ${ helperName } async initialized` )
224+
219225 helpers [ helperName ] = new ResolvedHelperClass ( config [ helperName ] )
220226 } )
221227
@@ -225,6 +231,7 @@ function createHelpers(config) {
225231 checkHelperRequirements ( HelperClass )
226232
227233 helpers [ helperName ] = new HelperClass ( config [ helperName ] )
234+ debug ( `helper ${ helperName } initialized` )
228235 } catch ( err ) {
229236 throw new Error ( `Could not load helper ${ helperName } (${ err . message } )` )
230237 }
@@ -322,6 +329,7 @@ function createSupportObjects(config) {
322329 if ( container . support [ name ] . _init ) {
323330 container . support [ name ] . _init ( )
324331 }
332+ debug ( `support object ${ name } initialized` )
325333 } catch ( err ) {
326334 throw new Error ( `Initialization failed for ${ name } : ${ container . support [ name ] } \n${ err . message } \n${ err . stack } ` )
327335 }
@@ -334,6 +342,7 @@ function createSupportObjects(config) {
334342 const ms = new MetaStep ( name , prop )
335343 ms . setContext ( currentObject )
336344 if ( isAsyncFunction ( currentValue ) ) currentValue = asyncWrapper ( currentValue )
345+ debug ( `metastep is created for ${ name } .${ prop . toString ( ) } ()` )
337346 return ms . run . bind ( ms , currentValue )
338347 }
339348
0 commit comments