How to replace mocha UTF8 checkmark symbol in jenkins

Viewed 909

When I run the mocha tests in jenkins, on the console output I can see â insetad of the (CHECK MARK) utf-8 character.

enter image description here

How can I replace these symbols to human readable format

2 Answers

Modify default reporter

The easiest way, to modify the default reporter of the mocha in the helper.js

helper.js

const mocha = require("mocha");
mocha.reporters.Base.symbols.ok = "[PASS]";
mocha.reporters.Base.symbols.err = "[FAIL]";

package.json

{
    ...
    "scripts": {
        ...
        "test": "mocha --require helpers.js"
    }
}

Use different reporter

Also you can use other reporters https://mochajs.org/#reporters

on karma.conf.js change the success mark

add those options:

module.exports = function(config) {
config.set({
frameworks: ['jasmine'],

// reporters configuration

reporters: ['mocha'],

// reporter options

mochaReporter: {
  symbols: {
    success: '+',
    info: '#',
    warning: '!',
    error: 'x'
  }
}

for more info use this link: enter link description here

this will generate the reports like so:

 spec name
    + first test
    + second test
    + third test 

instead of the defaults with the strange check mark symbol:

 spec name
        √ first test
        √ second test
        √ third test 
Related