Cucumber-js: Add support for custom formatters

Created on 19 Feb 2016  ·  17Comments  ·  Source: cucumber/cucumber-js

Previous PRs

215

257

309

Currently blocked on some work in progress that will change the formatters to look like the following

// suite - an event emitter
// log - function to call with output
// options - formatter options coming from cucumber
//   snippetGenerator - function to call to generate snippet for an undefined step
//   useColors - boolean of whether or not to use colors
function MyFormatter(suite, log, options) {
  suite.on('beforeFeatures', function () {});
  suite.on('beforeFeature', function (feature) {});
  suite.on('beforeScenario', function (scenario) {});
  suite.on('beforeStep', function (step) {});
  suite.on('stepResult', function (stepResult) {});
  suite.on('afterStep', function (step) {});
  suite.on('scenarioResult', function (scenarioResult) {});
  suite.on('afterScenario', function (scenario) {});
  suite.on('afterFeature', function (feature) {});
  suite.on('featuresResult', function (featuresResult) {});
  suite.on('afterFeatures', function () {});
}

Most helpful comment

Thank you guys very much for the offer to contribute! Just to give you some background on the work in progress. So one big thing for changing the formatters to this syntax is a complete rework of how cucumber hooks in the formatters. That resulted in the need to remove registerHandler, something that I believe is largely used for beforeAll / afterAll hooks but with an inconsistent interface. I have a branch that removes registerHandler. That however is dependent on updating to using gherkin4 which is waiting on a new release of gherkin in order to properly support the browser version.

I think I'll just manually fix the bug with gherkin for browser support so we can keep moving. Sorry this has taken so long. I really want to get all my existing work in which should help us get close to this.

For anyone willing to contribute, please either pick up an issue or ping me on gitter with something you would like to work on. I'd ask that you create your first PR from a fork. Once I've worked with you to get one of your PRs in, I'm happy to give you commit access to the repo.

All 17 comments

Just been reading through the previous PRs and this feels like the more ideal solution - let me know if there's anything I can do to assist in getting this pushed out :+1:

Also looking forward for this. Let me know If I can help :+1:

do we have ETA of this feature?

Any update on this? It seems as if this has been in the works for years....

Let us know if there's anything we can do to help.

+1, waiting for so long is painful

+1

@charlierudolph : I need this and I am also looking to pick up a open source project and contribute. I can work with @apbarrero or anyone else on this particular issue so we can get this out of door asap. I Also, I would love to be continuously contributing member. So, please guide me to become a contributing member. Thanks

Also willing to contribute.

Thank you guys very much for the offer to contribute! Just to give you some background on the work in progress. So one big thing for changing the formatters to this syntax is a complete rework of how cucumber hooks in the formatters. That resulted in the need to remove registerHandler, something that I believe is largely used for beforeAll / afterAll hooks but with an inconsistent interface. I have a branch that removes registerHandler. That however is dependent on updating to using gherkin4 which is waiting on a new release of gherkin in order to properly support the browser version.

I think I'll just manually fix the bug with gherkin for browser support so we can keep moving. Sorry this has taken so long. I really want to get all my existing work in which should help us get close to this.

For anyone willing to contribute, please either pick up an issue or ping me on gitter with something you would like to work on. I'd ask that you create your first PR from a fork. Once I've worked with you to get one of your PRs in, I'm happy to give you commit access to the repo.

+1

+1

Update: I am no longer planning on removing registerHandler. With version 1.1.0, I am happy enough with how registerHandler / formatters currently work. Adding support for this as part of 2.0 which I am working on now and is a rewrite of the codebase in ES6.

Added in 2.0.0-rc.1

I am using rc9 and the formatter folder does not contain a junit or tap formatter. nor does the --format option support them. Did I miss anything?

There is now support for custom formatters (see link on the readme) so for junit / tap formatters, those can be implemented as their own modules. I don't believe any are at the moment

For now, I am using https://github.com/stjohnjohnson/cucumber-junit which is not as nice as a native formatter, but works.

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings