@@ -22,25 +22,34 @@ var fs = require("fs");
2222
2323module . exports = function ( ) {
2424
25+ var driver = undefined ;
26+
2527 var failedScenarios = [ ] ;
2628
29+ this . registerHandler ( "BeforeFeatures" , function ( event , next ) {
30+ driver = neo4j . driver ( "bolt://localhost" , neo4j . auth . basic ( "neo4j" , "neo4j" ) ) ;
31+
32+ return next ( )
33+ } ) ;
34+
2735 this . Before ( "@reset_database" , function ( scenario , callback ) {
28- this . driver = neo4j . driver ( "bolt://localhost" , neo4j . auth . basic ( "neo4j" , "neo4j" ) ) ;
36+ this . driver = driver ;
2937 this . session = this . driver . session ( ) ;
3038 this . session . run ( "MATCH (n) DETACH DELETE n" ) . then ( function ( ) {
3139 callback ( ) ;
3240 } ) ;
3341 } ) ;
3442
3543 this . Before ( "@tls" , function ( scenario ) {
44+
3645 this . knownHosts1 = "known_hosts1" ;
3746 this . knownHosts2 = "known_hosts2" ;
3847 _deleteFile ( this . knownHosts1 ) ;
3948 _deleteFile ( this . knownHosts2 ) ;
4049 } ) ;
4150
4251 this . Before ( "~@reset_database" , "~@tls" , function ( scenario , callback ) {
43- this . driver = neo4j . driver ( "bolt://localhost" , neo4j . auth . basic ( "neo4j" , "neo4j" ) ) ;
52+ this . driver = driver ;
4453 this . session = this . driver . session ( ) ;
4554 callback ( ) ;
4655 } ) ;
@@ -50,8 +59,8 @@ module.exports = function () {
5059 } ) ;
5160
5261 this . After ( function ( scenario , callback ) {
53- if ( this . driver ) {
54- this . driver . close ( ) ;
62+ if ( this . session ) {
63+ this . session . close ( ) ;
5564 }
5665 if ( ! scenario . isSuccessful ( ) ) {
5766 failedScenarios . push ( scenario )
@@ -63,6 +72,9 @@ module.exports = function () {
6372 } ) ;
6473
6574 this . registerHandler ( 'AfterFeatures' , function ( event , callback ) {
75+ if ( driver ) {
76+ driver . close ( ) ;
77+ }
6678 if ( failedScenarios . length ) {
6779 for ( var i = 0 ; i < failedScenarios . length ; i ++ ) {
6880 console . log ( "FAILED! Scenario: " + failedScenarios [ i ] . getName ( ) ) ;
0 commit comments