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

Fix broken symbols when using node.js on Windows with default terminal fonts #641

Closed
wants to merge 5 commits into from

Conversation

jsalonen
Copy link
Contributor

@jsalonen jsalonen commented Nov 4, 2012

This pull request fixes - imho - a major annoyance with Mocha when running with node.js on Windows.

Several reporters (dot, list and spec) use special unicode symbols for visualising check marks (), error marks () and small dots ().

Sadly, default terminal fonts for Windows don't support these symbols. While mocha itself works just fine, it is somewhat annoying that your console gets filled with odd placeholder characters. This problem can be worked around by installing a custom font, such as DeJavu Sans Mono (http://stackoverflow.com/questions/9817926/how-can-i-get-mochas-unicode-output-to-display-properly-in-a-windows-console). Given this requires extra work, I'm pretty sure many developers just live with the broken symbols.

This pull request introduces a fix to this problem as follows:

  • A new, common symbol map containing symbols for check mark, error mark and small dots has been added to reporters/base.js
  • In case Node.js/Windows are detected, the default symbol map is modified to fall back to use symbols that are readily available on default console fonts
  • Reporters (dot, list, spec) have been modified to use special symbols from the symbol map

@domenic
Copy link
Contributor

domenic commented Nov 4, 2012

+1

@@ -277,7 +293,7 @@ Base.prototype.epilogue = function(){

// failure
if (stats.failures) {
fmt = color('bright fail', ' ✖')
fmt = color('bright fail', ' '+exports.symbols.err)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

' + exports..

@tj
Copy link
Contributor

tj commented Nov 6, 2012

windows should die, but ill merge after the style stuff is fixed

@jsalonen
Copy link
Contributor Author

jsalonen commented Nov 7, 2012

Thanks! Fixed. Also modified progress reporter similarly.

@tj
Copy link
Contributor

tj commented Nov 7, 2012

merged! thanks man

@tj tj closed this Nov 7, 2012
@jsalonen
Copy link
Contributor Author

jsalonen commented Nov 7, 2012

Thanks mate! This is awesome.

@silkentrance
Copy link

Great, now we have to include two sets of test fixtures, one for win32 and one for the rest of the platforms that are doing it correctly 😁

@silkentrance
Copy link

chcp 65001 anyone before running mocha? or will this not work?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants