Skip to content

Commit

Permalink
Fixed proper callback after all features
Browse files Browse the repository at this point in the history
  • Loading branch information
RagnarW committed Feb 17, 2016
1 parent 96c34f5 commit b763ca9
Showing 1 changed file with 21 additions and 15 deletions.
36 changes: 21 additions & 15 deletions test/v1/tck/steps/environment.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,38 @@ var neo4j = require("../../../../lib/v1");

module.exports = function () {

this.Before(function( scenario, callback ) {
var failedScenarios = []

this.Before("@reset_database", function( scenario, callback ) {
this.driver = neo4j.driver("bolt://localhost");
this.session = this.driver.session();
this.session.run("MATCH (n) DETACH DELETE n").then( function( ) {
callback();
});
callback();
});

this.Before("~@reset_database", function( scenario, callback ) {
this.driver = neo4j.driver("bolt://localhost");
this.session = this.driver.session();
if (findTag(scenario, '@reset_database')) {
this.session.run("MATCH (n) DETACH DELETE n").then( function( ) {
callback();
});
}
callback();
});

this.After(function (scenario, callback) {
if (!scenario.isSuccessful()) {
console.log("FAILED! Scenario: " + scenario.getName());
console.log("With Exception: " + scenario.getException());
return process.exit(2);
failedScenarios.push(scenario)
}
callback();
});

function findTag(scenario, tag) {
for (var i in scenario.getTags()) {
if (scenario.getTags()[i].getName() == tag) {
return true
this.registerHandler('AfterFeatures', function (event, callback) {
if (failedScenarios.length) {
for ( var i = 0; i < failedScenarios.length; i++) {
console.log("FAILED! Scenario: " + failedScenarios[i].getName());
console.log("With Exception: " + failedScenarios[i].getException() + "\n");
}
return process.exit(2);
}
return false;
}
callback();
});
}

0 comments on commit b763ca9

Please sign in to comment.