I just recognized that in one of my GitHub Action workflows which I ported over from travis no ANSI colors are shown in the Webview of the output. Is there some setting or are ANSI color escape sequences are simply stripped in GitHub Actions while with travis they are perfectly displayed in the webview?
In the actual job that is run I use the nodejs-based mocha test framework and in its output Mocha uses ANSI escape sequences to either show success with a green arrow or in case of a failure with a red cross and this works perfectly in the Travis webview while in the GitHub Actions job output view no ANSI colors are displayed at all.
So does anyone have an idea how to enable ANSI colors in the webview or is this simply a missing feature?!?
Thanks in advance.
Solved! Solved! Go to Solution.
Yes, we support ANSI colors.
I haven’t used Mocha specifically. Many test runners check for an env var or terminal setting before they output color.
Do you know which terminal settings or env variable as used to enable this is GitHub Actions? In fact, I already tried to set the TERM variable to "xterm-256color" right before starting the mocha test, but this didn't help. So I was wondering if there might be a standard TERM/ENV variable which I need to setup in the workflow and if so, why it is not setup per default as in travis I never had to care about that and ANSI color output is the default.
Hi @jens-maus ,
What do you mean of ‘ANSI color escape sequences’ here? Could you please show a screenshot in travis?
Checked on my side, with below command, the ANSI escape sequences works in bash output as expected.
echo -e "\033[31;1;4mHello\033[0m"
What do you mean of ‘ANSI color escape sequences’? Could you please show a screenshot?
I mean the following. This is the output on travis, e.g.:
And the same output, but on GitHub Actions looks like:
So please note the color difference and that within GitHub Actions no colorized output is presented at all. That's why I was wondering how to enable ANSI color output in GitHub Actions or if this is a missing feature.
Ok, after some more investigation I could solve the problem myself. I simply had to add the command-line option --colors when executing mocha (see https://github.com/jens-maus/occu-test/commit/0a57c8fadda3e7d4d8f2043c7171dc4d6a10966e).
So somehow with the default environment of GitHub Actions mocha could not identify itself that it is running within a TTY enabled device and thus enable ANSI color output itself. See here (https://github.com/mochajs/mocha/issues/1304) for similar discussions to force mocha to output ANSI colors on non tty devices. So the remaining question that might be there is, why isn't the GitHub Actions environment not identified as a proper TTY device by mocha while within travis there isn't any issue and mocha outputs all content using ANSI colors?!?