cucumber / cucumber-js-pretty-formatter

Cucumber.js pretty formatter
https://cucumber.io/
MIT License
18 stars 3 forks source link

Official Cucumber.js Pretty Formatter

build npm npm

The Cucumber.js pretty formatter logs your feature suite in its original Gherkin form. It offers custom style themes.

Install

The pretty formatter requires:

There are pretty formatters for older versions of Cucumber.

Usage

cucumber-js -f @cucumber/pretty-formatter

We recommend using Cucumber profiles to specify formatters.

Theme customisation

You can define your own colors by passing a theme format option:

--format-options '{"theme": <THEME_JSON>}'

Where THEME_JSON is in the following shape:

{"feature keyword": ["magenta", "bold"], "scenario keyword": ["red"]}

The customisable theme items are:

You can combine all the styles you'd like from modifiers, foreground colors and background colors exposed by ansi-styles.

Extending the Default Theme

If you just want to tweak a few things about the default theme without redefining it entirely, you can grab the default theme in your cucumber.js config file and use it as the base for yours:

const { DEFAULT_THEME } = require('@cucumber/pretty-formatter')

module.exports = {
  default: {
    formatOptions: {
      theme: {
        ...DEFAULT_THEME,
        'step text': 'magenta'
      }
    }
  }
}

Example Themes

Matrix

It could be called eco-friendly, cuz it's very green:

--format-options '{"theme":{"datatable border":["green"],"datatable content":["green","italic"],"docstring content":["green","italic"],"docstring delimiter":["green"],"feature description":["green"],"feature keyword":["bold","green"],"rule keyword":["yellow"],"scenario keyword":["greenBright"],"scenario name":["green","underline"],"step keyword":["bgGreen","black","italic"],"step text":["greenBright","italic"],"tag":["green"]}}'

Legacy pretty

This was the theme offered by Ilya Kozhevnikov's pretty formatter, pre-Cucumber.js 7.x.

--format-options '{"theme":{"feature keyword":["magenta","bold"],"scenario keyword":["magenta","bold"],"step keyword":["bold"]}}'

We need more themes

Please share your creations by forking, adding the theme to this section of the README and opening a pull request.

Older Cucumber versions

If you're using an older version of Cucumber.js, you'll need to use one of the previous pretty formatters:

Cucumber.js 1 → 2

The original pretty formatter used to ship with Cucumber. Simply specify it when invoking Cucumber:

cucumber-js -f pretty

Cucumber.js 3 → 6

You can install cucumber-pretty, created by Ilya Kozhevnikov.

Tell Cucumber to use it:

cucumber-js -f cucumber-pretty

Credits

This project is based on the original work of Ilya Kozhevnikov. It got migrated to TypeScript, upgraded for Cucumber.js 7+ that exposes cucumber-messages and is currently maintained by Julien Biezemans and the Cucumber team.