Skip to content

Instantly share code, notes, and snippets.

@upgundecha
Created February 19, 2017 15:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save upgundecha/03fec4595731c0933578beace7cd1c30 to your computer and use it in GitHub Desktop.
Save upgundecha/03fec4595731c0933578beace7cd1c30 to your computer and use it in GitHub Desktop.
cucumber-js hooks
var startTime;
module.exports = function() {
this.After(function (scenario, callback) {
console.log("Name >> " + scenario.getName());
console.log("Start Time >> " + startTime)
console.log("End Time >> " + new Date().getTime())
if(scenario.isSuccessful()) {
console.log("PASS");
} else if (scenario.isFailed()) {
console.log("FAIL");
} else if (scenario.isSkipped()) {
console.log("SKIPPED");
} else {
console.log("UNDEFINED");
}
callback();
});
this.Before(function (scenario, callback) {
startTime = new Date().getTime();
console.log("Keyword: " + scenario.getKeyword());
//console.log("Keyword: " + scenario.getUri());
var parts = scenario.getUri().split('/');
var item = parts.length - 1;
console.log('Feature >> ' + parts[item].replace('.feature', ''));
callback();
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment