Custom formatters should be a javascript class. The constructor will be an options object with the following properties:
colorFns
: a series of helper functions for outputting colors. See here. RespectscolorsEnabled
optioncwd
: the current working directoryeventBroadcaster
: an event emitter that emits cucumber-messageseventDataCollector
: an instance of EventDataCollector which handles the complexity of grouping the data for related eventslog
: function which will write the passed string to the the designated stream (stdout or the to file the formatter output is being redirected to).parsedArgvOptions
: an object of everything passed to--format-options
snippetBuilder
: an object with abuild
method that should be called with{keywordType, pickleStep}
. ThepickleStep
can be retrieved with theeventDataCollector
while thekeywordType
is complex to compute (see the SnippetsFormatter for an example).stream
: the underlying stream the formatter is writing to.log
is a shortcut for writing to it.supportCodeLibrary
: an object containing the step and hook definitions
The constructor of custom formatters should add listeners to the eventBroadcaster
.
See a couple examples here and the built in formatters here
The base Formatter
does very little aside from saving some of the options on the instance. You can extend the SummaryFormatter
(as the ProgressFormatter
and PrettyFormatter
do) in order to get the same error reporting at the end.
formatterHelpers
are also exposed to give some of the functionality in more modular pieces.
If there is any other formatter functionality you would like access to, please create an issue.