@@ -68,8 +68,8 @@ function World() {
6868 expect : expect , // expose chai expect to allow variable testing
6969 assert : assert , // expose chai assert to allow variable testing
7070 trace : consoleInfo , // expose an info method to log output to the console in a readable/visible format
71- page : { } , // empty page objects placeholder
72- shared : { } // empty shared objects placeholder
71+ page : global . page || { } , // empty page objects placeholder
72+ shared : global . shared || { } // empty shared objects placeholder
7373 } ;
7474
7575 // expose properties to step definition methods via global variables
@@ -78,7 +78,9 @@ function World() {
7878 // make property/method available as a global (no this. prefix required)
7979 global [ key ] = runtime [ key ] ;
8080 } ) ;
81+ }
8182
83+ function createGlobalObjects ( ) {
8284 // import shared objects from multiple paths (after global vars have been created)
8385 if ( global . sharedObjectPaths && Array . isArray ( global . sharedObjectPaths ) && global . sharedObjectPaths . length > 0 ) {
8486
@@ -107,10 +109,7 @@ function World() {
107109 if ( global . pageObjectPath && fs . existsSync ( global . pageObjectPath ) ) {
108110
109111 // require all page objects using camel case as object names
110- runtime . page = requireDir ( global . pageObjectPath , { camelcase : true } ) ;
111-
112- // expose globally
113- global . page = runtime . page ;
112+ global . page = requireDir ( global . pageObjectPath , { camelcase : true } ) ;
114113 }
115114
116115 // add helpers
@@ -119,6 +118,8 @@ function World() {
119118
120119// export the "World" required by cucumber to allow it to expose methods within step def's
121120module . exports = function ( ) {
121+ World ( ) ;
122+ createGlobalObjects ( ) ;
122123
123124 this . World = World ;
124125
0 commit comments