Console Colors for output #104

Closed
wants to merge 28 commits into
from

Conversation

Projects
None yet
Contributor

atrniv commented Dec 10, 2012

All formatter output colored results.
Pretty formatter now outputs filename and line numbers for steps and scenarios.
CUCUMBER_COLORS environment variable can be used to override default color formats.

Owner

jbpros commented Dec 10, 2012

I gave it a spin and it works well. I'll review the code in the next few days.

Thank you guys for the pull request.

Contributor

atrniv commented Dec 11, 2012

Your welcome, I also found a few more bugs during use and fixed them.

Cheers

Owner

jbpros commented Dec 11, 2012

I'm stressing out your branch locally on different projects. I have to admit it's pretty cool to leave the monochrome world ;)

Running cukejs's own suite with the pretty formatter fails, though:

jbpros@arwen:~/Projects/cucumber-js ‣ cucumber.js -f pretty
Feature: Asynchronous failing steps



/Users/jbpros/Projects/cucumber-js/lib/cucumber/listener/pretty_formatter.js:32
StepLength = scenario.getMaxStepLength() > scenario.getBackground().getMaxStep
                                                                    ^
TypeError: Cannot call method 'getMaxStepLength' of undefined
    at handleBeforeScenarioEvent (/Users/jbpros/Projects/cucumber-js/lib/cucumber/listener/pretty_formatter.js:32:83)
    at hear (/Users/jbpros/Projects/cucumber-js/lib/cucumber/listener.js:6:9)
    at self.hear (/Users/jbpros/Projects/cucumber-js/lib/cucumber/listener/pretty_formatter.js:17:7)
    at hear (/Users/jbpros/Projects/cucumber-js/lib/cucumber/listener.js:8:9)
    at self.hear (/Users/jbpros/Projects/cucumber-js/lib/cucumber/listener/summary_formatter.js:16:7)
    at handleBeforeScenarioEvent (/Users/jbpros/Projects/cucumber-js/lib/cucumber/listener/stats_journal.js:24:5)
    at Object.hear (/Users/jbpros/Projects/cucumber-js/lib/cucumber/listener.js:6:9)
    at Object.hear (/Users/jbpros/Projects/cucumber-js/lib/cucumber/listener/summary_formatter.js:15:18)
    at Object.hear (/Users/jbpros/Projects/cucumber-js/lib/cucumber/listener/pretty_formatter.js:16:22)
    at self.broadcastEvent (/Users/jbpros/Projects/cucumber-js/lib/cucumber/runtime/ast_tree_walker.js:111:49)
Contributor

atrniv commented Dec 11, 2012

I guess I missed this, all the test cases I ran against had backgrounds.
I totally forgot to try it with cucumber's own cukes, I just ran the progress formatter on them.
I fixed the issue, and I also took into account the case when a scenario name is longer than the background or scenario body.

Cuke's own suite should run without any hiccups now. :)

Owner

jbpros commented Dec 25, 2012

I'm now working on a merge of this. Thanks again.

This pull request is obviously touching much more than support for colours. While all your work is highly appreciated, I'd like to insist on the importance of keeping commits and pull requests focused on a single feature/bug. There are a couple of commits here that cover many different things and it's hard for us to discuss/rework independent pieces of code.

Thank you.

Contributor

atrniv commented Dec 30, 2012

Sorry for the trouble, its my first real contribution to a project on github.
Will keep it in mind next time. :)

Thanks

The coloured output works like a charm... 😄

+1, I was looking for this feature today and found this pull request. I'll try to give it a spin, but it would be really helpful.

behrang commented Mar 11, 2013

+1, It is very helpful for new adopters.

+1!

Comparing cucumber to vows, it's one of the few features I miss.

mikerobe commented Apr 9, 2013

+1. This looks very dated and takes longer to grok visually without color... not something to overlook

By the way, the color code for grey doesn't work in xterm or in the Terminal.app on OS X. It may be better to use the 256 color code instead of the apparently "not widely supported" (according to wikipedia) dimmer switch:

 -      'grey'          : '\033[2m\033[37m',
 +      'grey'          : '\033[38;5;8m',

Yes, we've been using this console coloured version of cucumber for quite some time now with no issues. The gray colour replacement is a good issue, but otherwise, given that this branch is good to merge, I hope this feature is fast-tracked to the master.
😄

+1! It is a lot more instigating to check the results using the colored output.

+1

lotyrin commented Jul 12, 2013

+1, is there anything left to be done on this?

+1 Is there any reason this isn't merged in yet? I have been using this with great success in a sample https://github.com/patrickarlt/cucumberjs-example.

Owner

jbpros commented Aug 13, 2013

@patrickarlt the tests need some rework. There's also a missing option to disable colors; this is important for CI servers, among other things.

jbpros closed this in 7dc33d4 Nov 27, 2013

@ldegen ldegen added a commit to ldegen/cucumber-js that referenced this pull request Jan 13, 2014

@atrniv @ldegen atrniv + ldegen Add colors to CLI (close #104)
Implemented colors and filenames, line number display in progress,
pretty and summary formatters along with support for environment
variable CUCUMBER_COLORS.

Squashed commit of the following:

commit 44c6757
Merge: 0411c18 53c3501
Author: Julien Biezemans <jb@jbpros.com>
Date:   Wed Nov 27 15:49:39 2013 +0100

    Merge branch 'master' into colors

    Conflicts:
    	lib/cucumber/cli.js
    	lib/cucumber/cli/argument_parser.js
    	lib/cucumber/cli/configuration.js
    	lib/cucumber/listener/progress_formatter.js
    	lib/cucumber/listener/summary_formatter.js
    	lib/cucumber/support_code.js
    	lib/cucumber/support_code/step_definition_snippet_builder_syntax.js
    	package.json
    	spec/cucumber/cli/configuration_spec.js
    	spec/cucumber/support_code/step_definition_snippet_builder_syntax_spec.js

commit 0411c18
Author: Julien Biezemans <jb@jbpros.com>
Date:   Tue Dec 25 23:28:48 2012 +0100

    Fix indentation

commit 0a62aea
Author: Julien Biezemans <jb@jbpros.com>
Date:   Tue Dec 25 23:14:39 2012 +0100

    Rename "coffee" internal formatter option to "coffeeScriptSnippets"

commit df69e13
Author: Julien Biezemans <jb@jbpros.com>
Date:   Tue Dec 25 23:12:19 2012 +0100

    Organize methods

commit fc662ed
Author: Julien Biezemans <jb@jbpros.com>
Date:   Tue Dec 25 23:11:39 2012 +0100

    Add missing specs to CLI configuration

commit 5ff71bb
Author: Julien Biezemans <jb@jbpros.com>
Date:   Tue Dec 25 22:17:01 2012 +0100

    Add argument parser specs for --coffee option

commit 38f5600
Author: Julien Biezemans <jb@jbpros.com>
Date:   Tue Dec 25 22:07:47 2012 +0100

    Remove useless newline

commit 9035433
Author: Julien Biezemans <jb@jbpros.com>
Date:   Tue Dec 25 22:06:51 2012 +0100

    Rename "feature tags" to "inherited tags"

commit 817c34c
Author: Julien Biezemans <jb@jbpros.com>
Date:   Tue Dec 25 21:53:06 2012 +0100

    Remove useless stub

commit 8a0ecab
Author: Johny Jose <johny.aiesec@gmail.com>
Date:   Thu Dec 13 00:18:00 2012 +0530

    removed debug code

commit c46cffb
Author: Johny Jose <johny.aiesec@gmail.com>
Date:   Wed Dec 12 23:03:45 2012 +0530

    Implemented stricter color formatting to prevent bugs with newline character. Added tags to pretty formatter output.

commit 260b595
Author: Johny Jose <johny.aiesec@gmail.com>
Date:   Wed Dec 12 04:10:21 2012 +0530

    Fixed bug with pretty formatter output in scenario without a background

commit 9403fa5
Author: Johny Jose <johny.aiesec@gmail.com>
Date:   Tue Dec 11 21:19:05 2012 +0530

    Fixed wrongly indented output for datatables when using colors.

commit e603982
Author: Johny Jose <johny.aiesec@gmail.com>
Date:   Tue Dec 11 14:52:35 2012 +0530

    Added proper filename and line indentation for background steps

commit 335b2da
Author: Johny Jose <johny.aiesec@gmail.com>
Date:   Tue Dec 11 12:12:45 2012 +0530

    Added coffeescript snippet support to the pretty formatter

commit ea2c3aa
Merge: f2c63c2 c09d4c6
Author: Johny Jose <johny.aiesec@gmail.com>
Date:   Mon Dec 10 15:04:32 2012 +0530

    Merge branch 'johngeorgewright'

commit f2c63c2
Author: Johny Jose <johny.aiesec@gmail.com>
Date:   Mon Dec 10 07:03:23 2012 +0530

    Updated step definitions for colored output.

commit e61e995
Author: Johny Jose <johny.aiesec@gmail.com>
Date:   Mon Dec 10 06:28:09 2012 +0530

    Implemented colors and filenames, line number display in progress, pretty and summary formatters along with support for environment variable CUCUMBER_COLORS.

commit c09d4c6
Author: John Wright <johngeorge.wright@gmail.com>
Date:   Thu Sep 13 22:29:04 2012 +1000

    Added a spec file for the syntax classes.

commit bdbf7a6
Author: John Wright <johngeorge.wright@gmail.com>
Date:   Thu Sep 13 22:24:57 2012 +1000

    Updated StepDefinitionSnippetBuilder spec file.

commit db0b8c3
Author: John Wright <johngeorge.wright@gmail.com>
Date:   Wed Sep 12 08:47:30 2012 +1000

    Updated tests for summary formatter.

commit aead79d
Author: John Wright <johngeorge.wright@gmail.com>
Date:   Wed Sep 12 08:46:55 2012 +1000

    The syntax construction now is created by a separate method. This makes things easier to test.

commit 705aca4
Author: John Wright <johngeorge.wright@gmail.com>
Date:   Tue Sep 11 20:31:38 2012 +1000

    #65 Getting Jamsine to pass.

commit b8b4780
Author: John Wright <johngeorge.wright@gmail.com>
Date:   Tue Sep 11 20:11:33 2012 +1000

    #65 Forgot about replacing the definition matching group parameters.

commit 878e8b8
Author: John Wright <johngeorge.wright@gmail.com>
Date:   Tue Sep 11 17:02:31 2012 +1000

    #65 The --coffee option will now switch the step definition builder between syntaxs.

commit d6ca30d
Author: John Wright <johngeorge.wright@gmail.com>
Date:   Tue Sep 11 17:01:26 2012 +1000

    #65 The step defintions snippets builder now uses a syntax behaviour rather then static properties. The CoffeeScript flavour has also been added here.
4eb64dc

Hi @jbpros,

Considering that this has now been merged, could you tell me how we can disable colors?
I checked in the readme but couldn't find anything regarding this feature.

Thanks!

I couldn't find a way to disable color either. It'd be a really nice addition.

djom20 commented May 2, 2017 edited

Hi, Is possible remove this colors of the console? Because I'm using jenkins and I can to see the colors like a plain text and this doesn't looks good for me. For example in the next Feature you can see the text [31m and [39m.

Scenario: the user filters by poll
Wrong label: @complete
Wrong label: @filters
Wrong label: @filtersByPoll
[31m✖ Given that the user has qrveys of "AudiencePoll" type�[39m
�[36m- And the user has login�[39m
[36m- When the user clicks on the "type" filter by dropdown type�[39m
[36m- And selects the "Poll" option in the filter type�[39m

Member

charlierudolph commented May 3, 2017 edited

I believe the cli option "--no-colors" will do it. Run "cucumber-js --help" to check

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment