@@ -72,17 +72,21 @@ function getDriverInstance() {
7272
7373
7474/**
75- * Initialize the eyes SDK and set your private API key via the config file.*/
75+ * Initialize the eyes SDK and set your private API key via the config file.
76+ */
7677function getEyesInstance ( ) {
7778
78- var eyes = new Eyes ( ) ;
79+ if ( global . eyesKey ) {
7980
80- //retrieve apikey from config file in the project root as defined by the user
81- eyes . setApiKey ( eyeskey ) ;
81+ var eyes = new Eyes ( ) ;
8282
83- return eyes ;
83+ // retrieve eyes api key from config file in the project root as defined by the user
84+ eyes . setApiKey ( global . eyesKey ) ;
8485
86+ return eyes ;
87+ }
8588
89+ return null ;
8690}
8791
8892function consoleInfo ( ) {
@@ -136,7 +140,7 @@ function importSupportObjects() {
136140
137141 if ( fs . existsSync ( itemPath ) ) {
138142
139- var dir = requireDir ( itemPath , { camelcase : true } ) ;
143+ var dir = requireDir ( itemPath , { camelcase : true } ) ;
140144
141145 merge ( allDirs , dir ) ;
142146 }
@@ -154,7 +158,7 @@ function importSupportObjects() {
154158 if ( global . pageObjectPath && fs . existsSync ( global . pageObjectPath ) ) {
155159
156160 // require all page objects using camel case as object names
157- global . page = requireDir ( global . pageObjectPath , { camelcase : true } ) ;
161+ global . page = requireDir ( global . pageObjectPath , { camelcase : true } ) ;
158162 }
159163
160164 // add helpers
@@ -178,9 +182,10 @@ module.exports = function () {
178182
179183 if ( ! global . driver || ! global . eyes ) {
180184 global . driver = getDriverInstance ( ) ;
185+
186+ // TOOD: this all feels a bit hacky, needs rethinking...
181187 global . eyes = getEyesInstance ( ) ;
182188 }
183-
184189 } ) ;
185190
186191 this . registerHandler ( 'AfterFeatures' , function ( features , done ) {
@@ -224,11 +229,17 @@ module.exports = function () {
224229
225230 return driver . close ( ) . then ( function ( ) {
226231 return driver . quit ( ) ;
227- } ) . then ( function ( ) {
228- // If the test was aborted before eyes.close was called ends the test as aborted.
229- return eyes . abortIfNotClosed ( ) ;
232+ } )
233+ . then ( function ( ) {
234+
235+ if ( eyes ) {
236+ // If the test was aborted before eyes.close was called ends the test as aborted.
237+ return eyes . abortIfNotClosed ( ) ;
238+ }
239+
240+ return Promise . resolve ( ) ;
230241 } ) ;
231- } )
242+ } ) ;
232243 }
233244
234245 return driver . close ( ) . then ( function ( ) {
0 commit comments