Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Please change color scheme #1200

Closed
octref opened this issue Apr 24, 2014 · 70 comments · Fixed by #1648
Closed

Please change color scheme #1200

octref opened this issue Apr 24, 2014 · 70 comments · Fixed by #1648
Labels
type: chore generally involving deps, tooling, configuration, etc.

Comments

@octref
Copy link

octref commented Apr 24, 2014

I've read through #802 and #590

I believe I've found where the issue lies:
Snippet from base.js
https://github.com/visionmedia/mocha/blob/master/lib/reporters/base.js

exports.colors = {
    'pass': 90
  , 'fail': 31
  , 'bright pass': 92
  , 'bright fail': 91
  , 'bright yellow': 93
  , 'pending': 36
  , 'suite': 0
  , 'error title': 0
  , 'error message': 31
  , 'error stack': 90
  , 'checkmark': 32
  , 'fast': 90
  , 'medium': 33
  , 'slow': 31
  , 'green': 32
  , 'light': 90
  , 'diff gutter': 90
  , 'diff added': 42
  , 'diff removed': 41
};

var color = exports.color = function(type, str) {
  if (!exports.useColors) return str;
  return '\u001b[' + exports.colors[type] + 'm' + str + '\u001b[0m';
};

So the color function takes in a type and uses the conversion table above to get the ANSI escape color.
A chart can be found here:
http://en.wikipedia.org/wiki/ANSI_escape_code#CSI_codes

As you can see:
screenshot from 2014-04-25 03 09 43

Seems to be a closed-source terminal from IBM AIX.
I believe nobody is using mocha on it. (Correct me if I'm wrong)

Furthermore, I found the ECMA specification:
http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-048.pdf
Here is page 62:
mocha2

Color 90-99 are not in the specification. Most terminals wouldn't care implementing these colors correctly and god knows what color they'll fall back into.
And not everyone uses iTerm2, which has a contrast setting.
Please use color 30-37, if you want increased intensity then \u001b[30;1m would use the intense variant.
I think users are only responsible for configuring their terminals so the 16 colors look great on their bg/fg colors. So please don't just say "It's the theme's fault" and close the issue. It's mocha's problem not using color from the standard palette.

@yoshuawuyts
Copy link

Can you PR it?

@timoxley
Copy link

timoxley commented May 8, 2014

@octref how many people are still using 16-colour terminals though?

@yoshuawuyts
Copy link

@timoxley afaik most people. Although nowadays you can choose what those colors look like.

@octref
Copy link
Author

octref commented May 13, 2014

@yoshuawuyts
Just made the request. Sorry I was new to git and github so it took me some time to learn it.
That's my first time making a PR. If there's anything wrong with it please let me know!

@octref
Copy link
Author

octref commented May 13, 2014

@timoxley
Do you mean that most people are using 256 color terminals?
That is not really related to ANSI escape code.

In ANSI escape code 30-37 correspond to the colors(red, green, blue, etc) defined in your terminal.
So if you do node -e "console.log('\33[31mfoo')", because 31 corresponds to red, the terminal will output the text in whatever color you defined for red.
But color 90-99 is not in the standard. So node -e "console.log('\33[91mfoo')" generates text in some text the users have no direct control of.

Mocha outputs a lot of message in color 90. https://github.com/visionmedia/mocha/pull/1212/files

In my theme color 90 is too close to my background color that I can't see it.
In the case of Solarized theme, color 90 also seems to produce color close to Solarized bg. See #802 and #590 .

@jeffmay
Copy link

jeffmay commented Oct 17, 2014

I don't really care about the framework. I just need to be able to run tests. I am going to switch to a different framework since the color scheme is basically unreadable, and I don't have time to figure out how to fix it.

Here is how it looks for me:
screen shot 2014-10-17 at 12 46 23 pm

It looks pretty terrible in every terminal color scheme I have, but in my favorite scheme, the stack trace is invisible.

@wilzbach
Copy link

+1 for pushing this :)

@jeffmay
Copy link

jeffmay commented Oct 17, 2014

In what terminal theme does a light green background color look good? I don't even know how mocha is supposed to look.

@MarcusSorealheis
Copy link

So you do care about Thea

On Oct 17, 2014, at 3:03 PM, Jeff May notifications@github.com wrote:

In what terminal theme does a light green background color look good? I don't even know how mocha is supposed to look.


Reply to this email directly or view it on GitHub.

@MarcusSorealheis
Copy link

So you do care about the framework of you need to run tests with it.

On Oct 17, 2014, at 3:03 PM, Jeff May notifications@github.com wrote:

In what terminal theme does a light green background color look good? I don't even know how mocha is supposed to look.


Reply to this email directly or view it on GitHub.

@jeffmay
Copy link

jeffmay commented Oct 17, 2014

I'm sorry. My message was confusing. I meant that I would be fine with a less powerful framework, so long as I can run tests that are visible. Mocha could be an awesome framework, but if my first experience with it is unreadable output, then I'm not going to care about how awesome it may be, I am going to switch to another framework.

This was the first experience I had with mocha, and then I searched the internet for why I can't customize the output, and a bunch of people are saying that it isn't something mocha needs to fix. But if it isn't mocha's responsibility to look good in the terminal, why should I even care about the rest of the framework? A lot of good work went into mocha. It sucks that people like me are being turned away by an odd / and mostly unreadable color scheme (I could post how it looks in all of my terminals, all of them look really bad).

And yes, I lied a bit. I do care about mocha. I want to use it. I like the async support (among other things). I'm just expressing the frustration of a newcomer who heard about how awesome it is, only to be turned away because I don't have a blessed terminal.

@jeffmay
Copy link

jeffmay commented Oct 17, 2014

These are the default terminal schemes, and it looks terrible in both:

screen shot 2014-10-17 at 3 19 03 pm
screen shot 2014-10-17 at 3 21 59 pm

Why can't I remove the green background?

@octref
Copy link
Author

octref commented Oct 18, 2014

@jeffmay
Just a temp fix.
Find lib/reporters/base.js
In line 66-67, change

  , 'diff added': 42
  , 'diff removed': 41

to

  , 'diff added': 32
  , 'diff removed': 31

@timshadel
Copy link

You can also do it at the top of your test, like this:

var colors = require('mocha/lib/reporters/base').colors;
colors['diff added'] = 32;
colors['diff removed'] = 31;

Again, not a wonderful solution, but the diffs are so much better.

@djensen47
Copy link

Based on @timshadel answer, I did something a little different. I explicitly set both the foreground and the background:

var colors = require('mocha/lib/reporters/base').colors;
colors['diff added'] = '30;42';
colors['diff removed'] = '30;41';

I have a test-helper.js file that all of my tests include anyway so this is an easy fix. Setting the foreground like this should probably get rolled into mocha. Just my two cents.

nylen added a commit to nylen/dotfiles that referenced this issue Mar 29, 2015
nylen added a commit to nylen/dotfiles that referenced this issue Apr 8, 2015
@nylen nylen mentioned this issue Apr 8, 2015
@legomind
Copy link

legomind commented Oct 7, 2015

This is still as issue when using solarized color scheme:

screenshot12

@mikeerickson
Copy link

Any chance this has been addressed somewhere that works with release version. I have tried all the various tweaks outlined above, but nothing works. My issue is that I cant see any of the messages in terminal (running MobaXterm on Windows).

@boneskull boneskull added the type: chore generally involving deps, tooling, configuration, etc. label Dec 2, 2015
@boneskull boneskull reopened this Dec 2, 2015
@octref
Copy link
Author

octref commented Dec 2, 2015

@boneskull
I just see this get reopened. How do you plan to fix it?

@boneskull
Copy link
Member

I'm just going to use chalk so nobody can complain Mocha uses weird ANSI escape sequences.

@boneskull
Copy link
Member

if people have a problem with the colors thereafter, it's really, truly, not Mocha's fault

@boneskull
Copy link
Member

(we're locked to v0.4.0 of chalk to keep node v0.8.0 support--its default npm version doesn't grok carets)

@boneskull
Copy link
Member

Yep. When I slide it to the left, nothing is shown.

You can see here that the problem is with the solarized theme itself:

image

@boneskull
Copy link
Member

boneskull commented Jul 1, 2016

While #2164 seems "more correct", and potentially a low-impact change, it won't help anybody running a "Solarized Dark" theme in iTerm.

Running the official "Solarized Dark" theme in Terminal.app seems to work fine without any modifications.

Let's recap:

  • OP complained about jacked-up color scheme
  • To the credit of the OP, at the time the "diff" colors were jacked-up
  • Someone sent a PR to fix the diff colors, and we merged that
  • Along the way, people were complaining that the "Solarized Dark" theme didn't work
  • tj was loathe to change the colors based on a a terminal theme some were using
  • Ostensibly to convince tj, users noted the reporters used non-standard ANSI colors
  • Others argued that you're unlikely to be using a terminal that doesn't support the non-standard colors
  • Later, I attempted to leverage the chalk module for colors so Mocha could absolve itself of choosing them (and finally end the debate), but that caused mass brokenness, and had to be reverted.
  • @jtangelder sent Fix non standard ANSI colors #2164, which removes the non-standard colors and uses "standard" ones
  • As some users suspected, the non-standard colors had no impact on some users of "Solarized Dark", who still have problems with visibility
  • In fact, certain users w/ certain terminal configurations can notice no difference whatsoever when the changes in Fix non standard ANSI colors #2164 are applied.

I can now say with certainty, _if the colors Mocha uses aren't visible, your color theme is broken and/or your terminal is misconfigured_. If you are having problems wherein Mocha fails to display visible text, you will also have problems using other programs which leverage the same ANSI colors.

If we changed the colors so theme A will display, there's no guarantee users of popular color theme B won't suffer invisible text as a result, because color theme B may be broken as well in a different manner. In either case, a terminal can be misconfigured.

I still may be interested in merging #2164, but I am going to close this ticket. It's not really in Mocha's best interest to play whack-a-mole with invisible terminal colors. While tj may have been ultimately correct--and I had suspected as much--neither one of us did a great job of communicating about it (nor did we expend the effort to produce examples).

If you are having this problem: Reconfigure your terminal and/or scheme to ensure all valid ANSI colors are clearly displayed.
For iTerm users: You can still use "Solarized Dark", but increase the "minimum contrast" setting.
For anyone else: I don't know; if you have a workaround, please post it here.

@dschinkel

This comment was marked as abuse.

@boneskull
Copy link
Member

Most people do not run their tests in console

Do you have data to support this?

I was able to try to tweak some things via the Webstorm IDE but still no luck

Mocha works fine for me in WebStorm terminal, using any color theme.

I understand you are frustrated, but I would prefer to leave this issue unlocked so people can post workarounds or proper terminal configurations.

@dschinkel

This comment was marked as abuse.

@dschinkel

This comment was marked as abuse.

@boneskull
Copy link
Member

So you're telling me most devs who use Sublime, Atom, Webstorm, etc. don't try using console embedded inside them and are always toggling back and fourth between their IDE or Editor and Console

I use Atom and WebStorm embedded terminals in addition to iTerm (all regularly), and have never had this problem.

@boneskull
Copy link
Member

inability to tweak mocha's default terrible color scheme.

You can't tweak its color scheme, but you can adjust your terminal. 😄

@jdmarshall
Copy link

jdmarshall commented Jul 1, 2016

I use Atom and WebStorm embedded terminals in addition to iTerm (all regularly), and have never had this problem.

It's a problem in the 'Darcula' theme, which almost everyone I observe using IntelliJ products seems to use now.

@dschinkel

This comment was marked as abuse.

@boneskull
Copy link
Member

@dschinkel

image

image

Before:

image

After:

image

@dschinkel

This comment was marked as abuse.

@boneskull
Copy link
Member

@jdmarshall thanks for the direction on that.

@boneskull
Copy link
Member

also note above "ANSI: black" is actually white.

@dschinkel

This comment was marked as abuse.

@dschinkel

This comment was marked as abuse.

@boneskull
Copy link
Member

Yep that's the work around I talked about. That makes the background of your console white for the terminal inside Webstorm.

There's is no need to make the background white, nor is that what my change in the screenshot did.

I'm trying to understand the problem you're seeing. If that "exception" text is too dark, make it lighter by increasing the brightness on the "dark gray":

image

image

If you're still having trouble, you may wish to consult the WebStorm documentation and/or contact someone at JetBrains.

@dschinkel

This comment was marked as abuse.

@boneskull
Copy link
Member

@dschinkel Put this file in your colors folder, then restart WebStorm.

On a mac, this is ~/Library/Prefernces/WebStorm<version>/colors/.

But that's about the extent of what I can do to support JetBrains' products. Again, this is not a Mocha-specific issue.

@dschinkel

This comment was marked as abuse.

@dschinkel

This comment was marked as abuse.

@jeffvandyke
Copy link

Just wanted to throw out there that I'm still bumping into this issue on gnome-terminal and xfce4-terminal, and I know this has a lot of talk, but as a new user of mocha, it's quite annoying :( It would be great if there was just a way to change, maybe via CLI, what color code gets used for secondary text output.

@r-tanner-f
Copy link

@jeffvandyke Are you using Solarized Dark? Much as I love the theme, it's simply broken. It uses Bright Black as the background color. Simple as that.

Take a look at the values section: http://ethanschoonover.com/solarized#the-values

And the usage guide: http://ethanschoonover.com/solarized/img/solarized-values-dark.png

If the background color was Black that might be forgivable, but I would never expect Bright Black to be the same as the background color. I've had this issue with other console applications and Solarized Dark as well. This isn't limited to Mocha at all.

@jeffvandyke
Copy link

Gotcha, that does make sense. My workaround was to set Bright Black to one of the lighter gray colors in my terminal, but I see how solarized dark doesn't fit perfectly for 16-color terminals. Thanks!

@tpict
Copy link

tpict commented Jan 22, 2018

Many of the popular base16 themes are also affected by this.

@mochajs mochajs locked and limited conversation to collaborators Jan 22, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: chore generally involving deps, tooling, configuration, etc.
Projects
None yet
Development

Successfully merging a pull request may close this issue.