Mocha: Doesn't colorize output in Git Bash terminal

Created on 16 Jun 2017  路  3Comments  路  Source: mochajs/mocha

bash.exe
Apparently colors work right:

mingw64__c_2017-06-16 12 47 10

git-bash.exe
Doesn't colorize output:

mingw64_ 2017-06-16 12 48 13

Why is it happening? How to fix it? I use git-bash.exe in my work, so it wold be great if you explain how to fix the issue.

question

Most helpful comment

I use mintty 2.0.3 via Git for Windows, and was having this problem. As @ScottFreeCode pointed out, mocha --colors solved this issue for me.

All 3 comments

I don't know the exact criteria off the top of my head, but there are heuristics such as is-a-tty that Mocha (and most colored commandline programs) use to tell when it's safe to provide color by default; in some cases those end up ambiguous or just incorrect and the program has to play it safe. Without looking into it more deeply I couldn't tell you for sure whether that's happening here, or whether there's a bug in git-bash, or in Mocha.

However! What I can say right now is that Mocha has a --colors option (or maybe it's --color; try both and see which one works) to override that and try to use color anyway.

I think it can be fixed just by:

export TERM=xterm-256color

I use mintty 2.0.3 via Git for Windows, and was having this problem. As @ScottFreeCode pointed out, mocha --colors solved this issue for me.

Was this page helpful?
0 / 5 - 0 ratings