mercredi 30 mars 2016

How to pretty format ansi characters in mocha console [0m xyz←[0m

I'm following this tutorial frontend-testing-with-phantomjs-casperjs-mocha-and-chai so that I can use mocha, chai, casperjs and phantomjs.

I can get code working, but I don't really understand how to format output so that it is readable.

I believe I may need to setup a mocha reporter, but I'm not quite sure if this is correct or how to go about it.

The output looks like this

←[0m←[0m
←[0m  xyz←[0m
111111111
←[2K←[0G  ←[32m  Ô£ô←[0m←[90m should dosomething←[0m
222222222222
←[2K←[0G  ←[32m  Ô£ô←[0m←[90m should dosomething else←[0m

Output

main.js

var config = require('./config');
var chai = require('chai');
var expect = chai.expect;
var code1 = require('./code1');
var Mocha = require('mocha');

var mocha = new Mocha({
  reporter: 'list'
});
//mocha.reporter('list').run();

describe('Home page', function () {
  before(function() {
    casper.start('http://ift.tt/YV9WJO');
  });

  it('should dosomething', function (done) {
    console.log('xxxxxxxxxx');
    done();
  });

  code1.go();
});

code1.js

module.exports = {
  go: describe('xyz', function() {

    it('should dos omething', function(done) {
      console.log('111111111');
      done();
    });

    it('should do something else', function (done) {
      console.log('222222222222');
      done();
    });
  })

};

Aucun commentaire:

Enregistrer un commentaire