UNPKG

morpha

Version:

A Web-IDE or Desktop-IDE creator.

94 lines (72 loc) 2.33 kB
'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = createProcessReporter; var _mocha = require('mocha'); var _mocha2 = _interopRequireDefault(_mocha); var _ms = require('mocha/lib/ms'); var _ms2 = _interopRequireDefault(_ms); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var Base = _mocha2.default.reporters.Base; var color = Base.color; function createProcessReporter(runner) { var indents = 0; var n = 0; function indent() { return Array(indents).join(' '); } runner.on('start', function () { console.log(''); }); runner.on('suite', function (suite) { ++indents; console.log(color('suite', '%s%s'), indent(), suite.title); }); runner.on('suite end', function () { --indents; if (indents === 1) { console.log(); } }); runner.on('pending', function (test) { var fmt = indent() + color('pending', ' - %s'); console.log(fmt, test.title); }); runner.on('pass', function (test) { var fmt = void 0; if (test.speed === 'fast') { fmt = indent() + color('checkmark', ' ' + Base.symbols.ok) + color('pass', ' %s'); console.log(fmt, test.title); } else { fmt = indent() + color('checkmark', ' ' + Base.symbols.ok) + color('pass', ' %s') + color(test.speed, ' (%dms)'); console.log(fmt, test.title, test.duration); } }); runner.on('fail', function (test) { console.log(indent() + color('fail', ' %d) %s'), ++n, test.title); }); runner.on('end', function (stats, failures) { var fmt = void 0; console.log(); // passes fmt = color('bright pass', ' ') + color('green', 'client %d passing') + color('light', ' (%s)'); console.log(fmt, stats.passes || 0, (0, _ms2.default)(stats.duration)); // pending if (stats.pending) { fmt = color('pending', ' ') + color('pending', 'client %d pending'); console.log(fmt, stats.pending); } // failures if (stats.failures) { fmt = color('fail', 'client %d failing'); console.log(fmt, stats.failures); failures.forEach(function (f, i) { console.log(f.fmt, i + 1, f.fullTitle, f.msg, f.stack); }); // console.log(failures) console.log(); } console.log(); }); }