Skip to content

Instantly share code, notes, and snippets.

@jbpros
Last active January 8, 2016 20:12
Show Gist options
  • Save jbpros/b677e929d219bc8a213b to your computer and use it in GitHub Desktop.
Save jbpros/b677e929d219bc8a213b to your computer and use it in GitHub Desktop.
A listener to log information about tags
// features/step_definitions/tag_logger.js
function TagLogger() {
var tags = {};
this.hear = function (event, callback) {
var eventName = event.getName();
switch (eventName) {
case 'BeforeScenario':
var scenario = event.getPayloadItem('scenario');
scenario.getTags().forEach(function (tag) {
var tagName = tag.getName();
tags[tagName] = (tags[tagName] || 0) + 1;
});
break
case 'AfterFeatures':
console.log("All tags:", tags);
}
callback();
};
}
module.exports = function () {
this.registerListener(new TagLogger())
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment