Question

I am one of the 10% of males who is colorblind, so I'm trying to configure my Behat CLI output to better distinguish between the yellow and green lines. This is generally supported, but judging from the docs, if I want to add an option such as underscore, I must also specify both foreground and background colors.

http://docs.behat.org/guides/7.config.html#colors

I wouldn't even mind if I had to redundantly define the fg color, but the default style does not apply a bg color, and I can't discover if the arguments can be configured so that they don't override the default.

Here is the example given:

default:
    formatter:
        name:               pretty
        parameters:
            output_styles:
                comment:    [ black, white, [ underscore ] ]

This is roughly what I'm after:

default:
    formatter:
        name:               pretty
        parameters:
            output_styles:
                undefined:  [ , , [ underscore ] ]

However, if I leave the first two arguments (or just the second argument) blank, I get an error like this:

[InvalidArgumentException]
    Invalid foreground color specified: "Array". Expected one of (black, red, green, yellow, blue, magenta, cyan, white)

It's not the end of the world, because I can simply specify both fg and bg colors, but since the defaults don't use bg colors, it ends up looking ugly.

Was it helpful?

Solution

I stumbled on the answer by trial and error:

default:
    formatter:
        name:               pretty
        parameters:
            output_styles:
                undefined:  [ null, null, [ underscore ] ]

After working with the styles and keeping them in sync with the documented color meanings (see http://docs.behat.org/guides/2.definitions.html#step-execution-result-types), I came up with the following settings which work well on dark and light terminal color schemes, and which also use non-color styles to differentiate result types:

default:
    formatter:
        name:               pretty
        parameters:
            output_styles:
              passed:                       [ white, green ]
              passed_param:                 [ white, green, [ bold ]]
              undefined:                    [ yellow, null, [ underscore, bold ]]
              pending:                      [ yellow, null, [ underscore ]]
              pending_param:                [ yellow, null, [ underscore, bold ]]
              failed:                       [ white, red ]
              failed_param:                 [ white, red, [ bold ]]
              skipped:                      [ cyan ]
              skipped_param:                [ cyan, null, [ bold ]]
              comment:                      [ cyan ]
              tag:                          [ cyan ]

Here's a screenshot of these output_styles on both a light and dark terminal:

enter image description here

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top