Added node modules
This commit is contained in:
236
node_modules/mocha/lib/reporters/base.js
generated
vendored
Normal file
236
node_modules/mocha/lib/reporters/base.js
generated
vendored
Normal file
@@ -0,0 +1,236 @@
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var tty = require('tty');
|
||||
|
||||
/**
|
||||
* Check if both stdio streams are associated with a tty.
|
||||
*/
|
||||
|
||||
var isatty = tty.isatty(1) && tty.isatty(2);
|
||||
|
||||
/**
|
||||
* Expose `Base`.
|
||||
*/
|
||||
|
||||
exports = module.exports = Base;
|
||||
|
||||
/**
|
||||
* Enable coloring by default.
|
||||
*/
|
||||
|
||||
exports.useColors = isatty;
|
||||
|
||||
/**
|
||||
* Default color map.
|
||||
*/
|
||||
|
||||
exports.colors = {
|
||||
'pass': 90
|
||||
, 'fail': 31
|
||||
, 'bright pass': 92
|
||||
, 'bright fail': 91
|
||||
, 'bright yellow': 93
|
||||
, 'pending': 36
|
||||
, 'suite': 0
|
||||
, 'error title': 0
|
||||
, 'error message': 31
|
||||
, 'error stack': 90
|
||||
, 'checkmark': 32
|
||||
, 'fast': 90
|
||||
, 'medium': 33
|
||||
, 'slow': 31
|
||||
, 'green': 32
|
||||
, 'light': 90
|
||||
};
|
||||
|
||||
/**
|
||||
* Color `str` with the given `type`,
|
||||
* allowing colors to be disabled,
|
||||
* as well as user-defined color
|
||||
* schemes.
|
||||
*
|
||||
* @param {String} type
|
||||
* @param {String} str
|
||||
* @return {String}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
var color = exports.color = function(type, str) {
|
||||
if (!exports.useColors) return str;
|
||||
return '\033[' + exports.colors[type] + 'm' + str + '\033[0m';
|
||||
};
|
||||
|
||||
/**
|
||||
* Expose term window size, with some
|
||||
* defaults for when stderr is not a tty.
|
||||
*/
|
||||
|
||||
exports.window = {
|
||||
width: isatty
|
||||
? process.stdout.getWindowSize
|
||||
? process.stdout.getWindowSize(1)[0]
|
||||
: tty.getWindowSize()[1]
|
||||
: 75
|
||||
};
|
||||
|
||||
/**
|
||||
* Expose some basic cursor interactions
|
||||
* that are common among reporters.
|
||||
*/
|
||||
|
||||
exports.cursor = {
|
||||
hide: function(){
|
||||
process.stdout.write('\033[?25l');
|
||||
},
|
||||
|
||||
show: function(){
|
||||
process.stdout.write('\033[?25h');
|
||||
},
|
||||
|
||||
deleteLine: function(){
|
||||
process.stdout.write('\033[2K');
|
||||
},
|
||||
|
||||
beginningOfLine: function(){
|
||||
process.stdout.write('\033[0G');
|
||||
},
|
||||
|
||||
CR: function(){
|
||||
exports.cursor.deleteLine();
|
||||
exports.cursor.beginningOfLine();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* A test is considered slow if it
|
||||
* exceeds the following value in milliseconds.
|
||||
*/
|
||||
|
||||
exports.slow = 75;
|
||||
|
||||
/**
|
||||
* Outut the given `failures` as a list.
|
||||
*
|
||||
* @param {Array} failures
|
||||
* @api public
|
||||
*/
|
||||
|
||||
exports.list = function(failures){
|
||||
console.error();
|
||||
failures.forEach(function(test, i){
|
||||
// format
|
||||
var fmt = color('error title', ' %s) %s:\n')
|
||||
+ color('error message', ' %s')
|
||||
+ color('error stack', '\n%s\n');
|
||||
|
||||
// msg
|
||||
var err = test.err
|
||||
, message = err.message || ''
|
||||
, stack = err.stack || message
|
||||
, index = stack.indexOf(message) + message.length
|
||||
, msg = stack.slice(0, index);
|
||||
|
||||
// indent stack trace without msg
|
||||
stack = stack.slice(index + 1)
|
||||
.replace(/^/gm, ' ');
|
||||
|
||||
console.error(fmt, (i + 1), test.fullTitle(), msg, stack);
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Initialize a new `Base` reporter.
|
||||
*
|
||||
* All other reporters generally
|
||||
* inherit from this reporter, providing
|
||||
* stats such as test duration, number
|
||||
* of tests passed / failed etc.
|
||||
*
|
||||
* @param {Runner} runner
|
||||
* @api public
|
||||
*/
|
||||
|
||||
function Base(runner) {
|
||||
var self = this
|
||||
, stats = this.stats = { suites: 0, tests: 0, passes: 0, failures: 0 }
|
||||
, failures = this.failures = [];
|
||||
|
||||
if (!runner) return;
|
||||
this.runner = runner;
|
||||
|
||||
runner.on('start', function(){
|
||||
stats.start = new Date;
|
||||
});
|
||||
|
||||
runner.on('suite', function(suite){
|
||||
stats.suites = stats.suites || 0;
|
||||
suite.root || stats.suites++;
|
||||
});
|
||||
|
||||
runner.on('test end', function(test){
|
||||
stats.tests = stats.tests || 0;
|
||||
stats.tests++;
|
||||
});
|
||||
|
||||
runner.on('pass', function(test){
|
||||
stats.passes = stats.passes || 0;
|
||||
|
||||
var medium = exports.slow / 2;
|
||||
test.speed = test.duration > exports.slow
|
||||
? 'slow'
|
||||
: test.duration > medium
|
||||
? 'medium'
|
||||
: 'fast';
|
||||
|
||||
stats.passes++;
|
||||
});
|
||||
|
||||
runner.on('fail', function(test, err){
|
||||
stats.failures = stats.failures || 0;
|
||||
stats.failures++;
|
||||
test.err = err;
|
||||
failures.push(test);
|
||||
});
|
||||
|
||||
runner.on('end', function(){
|
||||
stats.end = new Date;
|
||||
stats.duration = new Date - stats.start;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Output common epilogue used by many of
|
||||
* the bundled reporters.
|
||||
*
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Base.prototype.epilogue = function(){
|
||||
var stats = this.stats
|
||||
, fmt;
|
||||
|
||||
console.log();
|
||||
|
||||
// failure
|
||||
if (stats.failures) {
|
||||
fmt = color('bright fail', ' ✖')
|
||||
+ color('fail', ' %d of %d tests failed')
|
||||
+ color('light', ':')
|
||||
|
||||
console.error(fmt, stats.failures, this.runner.total);
|
||||
Base.list(this.failures);
|
||||
console.error();
|
||||
return;
|
||||
}
|
||||
|
||||
// pass
|
||||
fmt = color('bright pass', ' ✔')
|
||||
+ color('green', ' %d tests complete')
|
||||
+ color('light', ' (%dms)');
|
||||
|
||||
console.log(fmt, stats.tests || 0, stats.duration);
|
||||
console.log();
|
||||
};
|
||||
74
node_modules/mocha/lib/reporters/doc.js
generated
vendored
Normal file
74
node_modules/mocha/lib/reporters/doc.js
generated
vendored
Normal file
@@ -0,0 +1,74 @@
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var Base = require('./base')
|
||||
, utils = require('../utils');
|
||||
|
||||
/**
|
||||
* Expose `Doc`.
|
||||
*/
|
||||
|
||||
exports = module.exports = Doc;
|
||||
|
||||
/**
|
||||
* Initialize a new `Doc` reporter.
|
||||
*
|
||||
* @param {Runner} runner
|
||||
* @api public
|
||||
*/
|
||||
|
||||
function Doc(runner) {
|
||||
Base.call(this, runner);
|
||||
|
||||
var self = this
|
||||
, stats = this.stats
|
||||
, total = runner.total
|
||||
, indents = 2;
|
||||
|
||||
function indent() {
|
||||
return Array(indents).join(' ');
|
||||
}
|
||||
|
||||
runner.on('suite', function(suite){
|
||||
if (suite.root) return;
|
||||
++indents;
|
||||
console.log('%s<section class="suite">', indent());
|
||||
++indents;
|
||||
console.log('%s<h1>%s</h1>', indent(), suite.title);
|
||||
console.log('%s<dl>', indent());
|
||||
});
|
||||
|
||||
runner.on('suite end', function(suite){
|
||||
if (suite.root) return;
|
||||
console.log('%s</dl>', indent());
|
||||
--indents;
|
||||
console.log('%s</section>', indent());
|
||||
--indents;
|
||||
});
|
||||
|
||||
runner.on('pass', function(test){
|
||||
console.log('%s <dt>%s</dt>', indent(), test.title);
|
||||
var code = utils.escape(clean(test.fn.toString()));
|
||||
console.log('%s <dd><pre><code>%s</code></pre></dd>', indent(), code);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Strip the function definition from `str`,
|
||||
* and re-indent for pre whitespace.
|
||||
*/
|
||||
|
||||
function clean(str) {
|
||||
str = str
|
||||
.replace(/^function *\(.*\) *{/, '')
|
||||
.replace(/\s+\}$/, '');
|
||||
|
||||
var spaces = str.match(/^\n?( *)/)[1].length
|
||||
, re = new RegExp('^ {' + spaces + '}', 'gm');
|
||||
|
||||
str = str.replace(re, '');
|
||||
|
||||
return str;
|
||||
}
|
||||
62
node_modules/mocha/lib/reporters/dot.js
generated
vendored
Normal file
62
node_modules/mocha/lib/reporters/dot.js
generated
vendored
Normal file
@@ -0,0 +1,62 @@
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var Base = require('./base')
|
||||
, color = Base.color;
|
||||
|
||||
/**
|
||||
* Expose `Dot`.
|
||||
*/
|
||||
|
||||
exports = module.exports = Dot;
|
||||
|
||||
/**
|
||||
* Initialize a new `Dot` matrix test reporter.
|
||||
*
|
||||
* @param {Runner} runner
|
||||
* @api public
|
||||
*/
|
||||
|
||||
function Dot(runner) {
|
||||
Base.call(this, runner);
|
||||
|
||||
var self = this
|
||||
, stats = this.stats
|
||||
, width = Base.window.width * .75 | 0
|
||||
, n = 0;
|
||||
|
||||
runner.on('start', function(){
|
||||
process.stdout.write('\n ');
|
||||
});
|
||||
|
||||
runner.on('pending', function(test){
|
||||
process.stdout.write(color('pending', '.'));
|
||||
});
|
||||
|
||||
runner.on('pass', function(test){
|
||||
if (++n % width == 0) process.stdout.write('\n ');
|
||||
if ('slow' == test.speed) {
|
||||
process.stdout.write(color('bright yellow', '.'));
|
||||
} else {
|
||||
process.stdout.write(color(test.speed, '.'));
|
||||
}
|
||||
});
|
||||
|
||||
runner.on('fail', function(test, err){
|
||||
if (++n % width == 0) process.stdout.write('\n ');
|
||||
process.stdout.write(color('fail', '.'));
|
||||
});
|
||||
|
||||
runner.on('end', function(){
|
||||
console.log();
|
||||
self.epilogue();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Inherit from `Base.prototype`.
|
||||
*/
|
||||
|
||||
Dot.prototype.__proto__ = Base.prototype;
|
||||
154
node_modules/mocha/lib/reporters/html.js
generated
vendored
Normal file
154
node_modules/mocha/lib/reporters/html.js
generated
vendored
Normal file
@@ -0,0 +1,154 @@
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var Base = require('./base')
|
||||
, utils = require('../utils')
|
||||
, Progress = require('../browser/progress')
|
||||
, escape = utils.escape;
|
||||
|
||||
/**
|
||||
* Expose `Doc`.
|
||||
*/
|
||||
|
||||
exports = module.exports = HTML;
|
||||
|
||||
/**
|
||||
* Stats template.
|
||||
*/
|
||||
|
||||
var statsTemplate = '<ul id="stats">'
|
||||
+ '<li class="progress"><canvas width="40" height="40"></canvas></li>'
|
||||
+ '<li class="passes">passes: <em>0</em></li>'
|
||||
+ '<li class="failures">failures: <em>0</em></li>'
|
||||
+ '<li class="duration">duration: <em>0</em>s</li>'
|
||||
+ '</ul>';
|
||||
|
||||
/**
|
||||
* Initialize a new `Doc` reporter.
|
||||
*
|
||||
* @param {Runner} runner
|
||||
* @api public
|
||||
*/
|
||||
|
||||
function HTML(runner) {
|
||||
Base.call(this, runner);
|
||||
|
||||
// TODO: clean up
|
||||
|
||||
var self = this
|
||||
, stats = this.stats
|
||||
, total = runner.total
|
||||
, root = $('#mocha')
|
||||
, stack = [root]
|
||||
, stat = $(statsTemplate).appendTo(root)
|
||||
, canvas = stat.find('canvas').get(0)
|
||||
, progress
|
||||
, ctx
|
||||
|
||||
if (canvas.getContext) {
|
||||
ctx = canvas.getContext('2d');
|
||||
progress = new Progress;
|
||||
}
|
||||
|
||||
if (!root.length) return error('#mocha div missing, add it to your document');
|
||||
|
||||
if (progress) progress.size(40);
|
||||
|
||||
runner.on('suite', function(suite){
|
||||
if (suite.root) return;
|
||||
|
||||
// suite
|
||||
var el = $('<div class="suite"><h1>' + suite.title + '</h1></div>');
|
||||
|
||||
// container
|
||||
stack[0].append(el);
|
||||
stack.unshift($('<div>'));
|
||||
el.append(stack[0]);
|
||||
});
|
||||
|
||||
runner.on('suite end', function(suite){
|
||||
if (suite.root) return;
|
||||
stack.shift();
|
||||
});
|
||||
|
||||
runner.on('fail', function(test, err){
|
||||
if (err.uncaught) runner.emit('test end', test);
|
||||
});
|
||||
|
||||
runner.on('test end', function(test){
|
||||
// TODO: add to stats
|
||||
var percent = stats.tests / total * 100 | 0;
|
||||
|
||||
if (progress) {
|
||||
progress.update(percent).draw(ctx);
|
||||
}
|
||||
|
||||
// update stats
|
||||
var ms = new Date - stats.start;
|
||||
stat.find('.passes em').text(stats.passes);
|
||||
stat.find('.failures em').text(stats.failures);
|
||||
stat.find('.duration em').text((ms / 1000).toFixed(2));
|
||||
|
||||
// test
|
||||
if (test.passed) {
|
||||
var el = $('<div class="test pass"><h2>' + escape(test.title) + '</h2></div>')
|
||||
} else if (test.pending) {
|
||||
var el = $('<div class="test pass pending"><h2>' + escape(test.title) + '</h2></div>')
|
||||
} else {
|
||||
var el = $('<div class="test fail"><h2>' + escape(test.title) + '</h2></div>');
|
||||
var str = test.err.stack || test.err;
|
||||
|
||||
// <=IE7 stringifies to [Object Error]. Since it can be overloaded, we
|
||||
// check for the result of the stringifying.
|
||||
if ('[object Error]' == str) str = test.err.message;
|
||||
|
||||
$('<pre class="error">' + escape(str) + '</pre>').appendTo(el);
|
||||
}
|
||||
|
||||
// toggle code
|
||||
el.find('h2').toggle(function(){
|
||||
pre && pre.slideDown('fast');
|
||||
}, function(){
|
||||
pre && pre.slideUp('fast');
|
||||
});
|
||||
|
||||
// code
|
||||
// TODO: defer
|
||||
if (!test.pending) {
|
||||
var code = escape(clean(test.fn.toString()));
|
||||
var pre = $('<pre><code>' + code + '</code></pre>');
|
||||
pre.appendTo(el).hide();
|
||||
}
|
||||
stack[0].append(el);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Display error `msg`.
|
||||
*/
|
||||
|
||||
function error(msg) {
|
||||
$('<div id="error">' + msg + '</div>').appendTo('body');
|
||||
}
|
||||
|
||||
/**
|
||||
* Strip the function definition from `str`,
|
||||
* and re-indent for pre whitespace.
|
||||
*/
|
||||
|
||||
function clean(str) {
|
||||
str = str
|
||||
.replace(/^function *\(.*\) *{/, '')
|
||||
.replace(/\s+\}$/, '');
|
||||
|
||||
var spaces = str.match(/^\n?( *)/)[1].length
|
||||
, re = new RegExp('^ {' + spaces + '}', 'gm');
|
||||
|
||||
str = str
|
||||
.replace(re, '')
|
||||
.replace(/^\s+/, '');
|
||||
|
||||
return str;
|
||||
}
|
||||
13
node_modules/mocha/lib/reporters/index.js
generated
vendored
Normal file
13
node_modules/mocha/lib/reporters/index.js
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
|
||||
exports.Base = require('./base');
|
||||
exports.Dot = require('./dot');
|
||||
exports.Doc = require('./doc');
|
||||
exports.TAP = require('./tap');
|
||||
exports.JSON = require('./json');
|
||||
exports.HTML = require('./html');
|
||||
exports.List = require('./list');
|
||||
exports.Spec = require('./spec');
|
||||
exports.Progress = require('./progress');
|
||||
exports.Landing = require('./landing');
|
||||
exports.JSONStream = require('./json-stream');
|
||||
exports.XUnit = require('./xunit')
|
||||
61
node_modules/mocha/lib/reporters/json-stream.js
generated
vendored
Normal file
61
node_modules/mocha/lib/reporters/json-stream.js
generated
vendored
Normal file
@@ -0,0 +1,61 @@
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var Base = require('./base')
|
||||
, color = Base.color;
|
||||
|
||||
/**
|
||||
* Expose `List`.
|
||||
*/
|
||||
|
||||
exports = module.exports = List;
|
||||
|
||||
/**
|
||||
* Initialize a new `List` test reporter.
|
||||
*
|
||||
* @param {Runner} runner
|
||||
* @api public
|
||||
*/
|
||||
|
||||
function List(runner) {
|
||||
Base.call(this, runner);
|
||||
|
||||
var self = this
|
||||
, stats = this.stats
|
||||
, total = runner.total;
|
||||
|
||||
runner.on('start', function(){
|
||||
console.log(JSON.stringify(['start', { total: total }]));
|
||||
});
|
||||
|
||||
runner.on('pass', function(test){
|
||||
console.log(JSON.stringify(['pass', clean(test)]));
|
||||
});
|
||||
|
||||
runner.on('fail', function(test, err){
|
||||
console.log(JSON.stringify(['fail', clean(test)]));
|
||||
});
|
||||
|
||||
runner.on('end', function(){
|
||||
process.stdout.write(JSON.stringify(['end', self.stats]));
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a plain-object representation of `test`
|
||||
* free of cyclic properties etc.
|
||||
*
|
||||
* @param {Object} test
|
||||
* @return {Object}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function clean(test) {
|
||||
return {
|
||||
title: test.title
|
||||
, fullTitle: test.fullTitle()
|
||||
, duration: test.duration
|
||||
}
|
||||
}
|
||||
70
node_modules/mocha/lib/reporters/json.js
generated
vendored
Normal file
70
node_modules/mocha/lib/reporters/json.js
generated
vendored
Normal file
@@ -0,0 +1,70 @@
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var Base = require('./base')
|
||||
, cursor = Base.cursor
|
||||
, color = Base.color;
|
||||
|
||||
/**
|
||||
* Expose `JSON`.
|
||||
*/
|
||||
|
||||
exports = module.exports = JSONReporter;
|
||||
|
||||
/**
|
||||
* Initialize a new `JSON` reporter.
|
||||
*
|
||||
* @param {Runner} runner
|
||||
* @api public
|
||||
*/
|
||||
|
||||
function JSONReporter(runner) {
|
||||
var self = this;
|
||||
Base.call(this, runner);
|
||||
|
||||
var tests = []
|
||||
, failures = []
|
||||
, passes = [];
|
||||
|
||||
runner.on('test end', function(test){
|
||||
tests.push(test);
|
||||
});
|
||||
|
||||
runner.on('pass', function(test){
|
||||
passes.push(test);
|
||||
});
|
||||
|
||||
runner.on('fail', function(test){
|
||||
failures.push(test);
|
||||
});
|
||||
|
||||
runner.on('end', function(){
|
||||
var obj = {
|
||||
stats: self.stats
|
||||
, tests: tests.map(clean)
|
||||
, failures: failures.map(clean)
|
||||
, passes: passes.map(clean)
|
||||
};
|
||||
|
||||
process.stdout.write(JSON.stringify(obj));
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a plain-object representation of `test`
|
||||
* free of cyclic properties etc.
|
||||
*
|
||||
* @param {Object} test
|
||||
* @return {Object}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function clean(test) {
|
||||
return {
|
||||
title: test.title
|
||||
, fullTitle: test.fullTitle()
|
||||
, duration: test.duration
|
||||
}
|
||||
}
|
||||
97
node_modules/mocha/lib/reporters/landing.js
generated
vendored
Normal file
97
node_modules/mocha/lib/reporters/landing.js
generated
vendored
Normal file
@@ -0,0 +1,97 @@
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var Base = require('./base')
|
||||
, cursor = Base.cursor
|
||||
, color = Base.color;
|
||||
|
||||
/**
|
||||
* Expose `Landing`.
|
||||
*/
|
||||
|
||||
exports = module.exports = Landing;
|
||||
|
||||
/**
|
||||
* Airplane color.
|
||||
*/
|
||||
|
||||
Base.colors.plane = 0;
|
||||
|
||||
/**
|
||||
* Airplane crash color.
|
||||
*/
|
||||
|
||||
Base.colors['plane crash'] = 31;
|
||||
|
||||
/**
|
||||
* Runway color.
|
||||
*/
|
||||
|
||||
Base.colors.runway = 90;
|
||||
|
||||
/**
|
||||
* Initialize a new `Landing` reporter.
|
||||
*
|
||||
* @param {Runner} runner
|
||||
* @api public
|
||||
*/
|
||||
|
||||
function Landing(runner) {
|
||||
Base.call(this, runner);
|
||||
|
||||
var self = this
|
||||
, stats = this.stats
|
||||
, width = Base.window.width * .75 | 0
|
||||
, total = runner.total
|
||||
, stream = process.stdout
|
||||
, plane = color('plane', '✈')
|
||||
, crashed = -1
|
||||
, n = 0;
|
||||
|
||||
function runway() {
|
||||
var buf = Array(width).join('-');
|
||||
return ' ' + color('runway', buf);
|
||||
}
|
||||
|
||||
runner.on('start', function(){
|
||||
stream.write('\n ');
|
||||
cursor.hide();
|
||||
});
|
||||
|
||||
runner.on('test end', function(test){
|
||||
// check if the plane crashed
|
||||
var col = -1 == crashed
|
||||
? width * ++n / total | 0
|
||||
: crashed;
|
||||
|
||||
// show the crash
|
||||
if (test.failed) {
|
||||
plane = color('plane crash', '✈');
|
||||
crashed = col;
|
||||
}
|
||||
|
||||
// render landing strip
|
||||
stream.write('\033[4F\n\n');
|
||||
stream.write(runway());
|
||||
stream.write('\n ');
|
||||
stream.write(color('runway', Array(col).join('⋅')));
|
||||
stream.write(plane)
|
||||
stream.write(color('runway', Array(width - col).join('⋅') + '\n'));
|
||||
stream.write(runway());
|
||||
stream.write('\033[0m');
|
||||
});
|
||||
|
||||
runner.on('end', function(){
|
||||
cursor.show();
|
||||
console.log();
|
||||
self.epilogue();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Inherit from `Base.prototype`.
|
||||
*/
|
||||
|
||||
Landing.prototype.__proto__ = Base.prototype;
|
||||
64
node_modules/mocha/lib/reporters/list.js
generated
vendored
Normal file
64
node_modules/mocha/lib/reporters/list.js
generated
vendored
Normal file
@@ -0,0 +1,64 @@
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var Base = require('./base')
|
||||
, cursor = Base.cursor
|
||||
, color = Base.color;
|
||||
|
||||
/**
|
||||
* Expose `List`.
|
||||
*/
|
||||
|
||||
exports = module.exports = List;
|
||||
|
||||
/**
|
||||
* Initialize a new `List` test reporter.
|
||||
*
|
||||
* @param {Runner} runner
|
||||
* @api public
|
||||
*/
|
||||
|
||||
function List(runner) {
|
||||
Base.call(this, runner);
|
||||
|
||||
var self = this
|
||||
, stats = this.stats
|
||||
, n = 0;
|
||||
|
||||
runner.on('start', function(){
|
||||
console.log();
|
||||
});
|
||||
|
||||
runner.on('test', function(test){
|
||||
process.stdout.write(color('pass', ' ' + test.fullTitle() + ': '));
|
||||
});
|
||||
|
||||
runner.on('pending', function(test){
|
||||
var fmt = color('checkmark', ' -')
|
||||
+ color('pending', ' %s');
|
||||
console.log(fmt, test.fullTitle());
|
||||
});
|
||||
|
||||
runner.on('pass', function(test){
|
||||
var fmt = color('checkmark', ' ✓')
|
||||
+ color('pass', ' %s: ')
|
||||
+ color(test.speed, '%dms');
|
||||
cursor.CR();
|
||||
console.log(fmt, test.fullTitle(), test.duration);
|
||||
});
|
||||
|
||||
runner.on('fail', function(test, err){
|
||||
cursor.CR();
|
||||
console.log(color('fail', ' %d) %s'), ++n, test.fullTitle());
|
||||
});
|
||||
|
||||
runner.on('end', self.epilogue.bind(self));
|
||||
}
|
||||
|
||||
/**
|
||||
* Inherit from `Base.prototype`.
|
||||
*/
|
||||
|
||||
List.prototype.__proto__ = Base.prototype;
|
||||
85
node_modules/mocha/lib/reporters/progress.js
generated
vendored
Normal file
85
node_modules/mocha/lib/reporters/progress.js
generated
vendored
Normal file
@@ -0,0 +1,85 @@
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var Base = require('./base')
|
||||
, cursor = Base.cursor
|
||||
, color = Base.color;
|
||||
|
||||
/**
|
||||
* Expose `Progress`.
|
||||
*/
|
||||
|
||||
exports = module.exports = Progress;
|
||||
|
||||
/**
|
||||
* General progress bar color.
|
||||
*/
|
||||
|
||||
Base.colors.progress = 90;
|
||||
|
||||
/**
|
||||
* Initialize a new `Progress` bar test reporter.
|
||||
*
|
||||
* @param {Runner} runner
|
||||
* @param {Object} options
|
||||
* @api public
|
||||
*/
|
||||
|
||||
function Progress(runner, options) {
|
||||
Base.call(this, runner);
|
||||
|
||||
var self = this
|
||||
, options = options || {}
|
||||
, stats = this.stats
|
||||
, width = Base.window.width * .50 | 0
|
||||
, total = runner.total
|
||||
, complete = 0
|
||||
, max = Math.max;
|
||||
|
||||
// default chars
|
||||
options.open = options.open || '[';
|
||||
options.complete = options.complete || '▬';
|
||||
options.incomplete = options.incomplete || '⋅';
|
||||
options.close = options.close || ']';
|
||||
options.verbose = false;
|
||||
|
||||
// tests started
|
||||
runner.on('start', function(){
|
||||
console.log();
|
||||
cursor.hide();
|
||||
});
|
||||
|
||||
// tests complete
|
||||
runner.on('test end', function(){
|
||||
var incomplete = total - complete
|
||||
, percent = complete++ / total
|
||||
, n = width * percent | 0
|
||||
, i = width - n;
|
||||
|
||||
cursor.CR();
|
||||
process.stdout.write('\033[J');
|
||||
process.stdout.write(color('progress', ' ' + options.open));
|
||||
process.stdout.write(Array(n).join(options.complete));
|
||||
process.stdout.write(Array(i).join(options.incomplete));
|
||||
process.stdout.write(color('progress', options.close));
|
||||
if (options.verbose) {
|
||||
process.stdout.write(color('progress', ' ' + complete + ' of ' + total));
|
||||
}
|
||||
});
|
||||
|
||||
// tests are complete, output some stats
|
||||
// and the failures if any
|
||||
runner.on('end', function(){
|
||||
cursor.show();
|
||||
console.log();
|
||||
self.epilogue();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Inherit from `Base.prototype`.
|
||||
*/
|
||||
|
||||
Progress.prototype.__proto__ = Base.prototype;
|
||||
87
node_modules/mocha/lib/reporters/spec.js
generated
vendored
Normal file
87
node_modules/mocha/lib/reporters/spec.js
generated
vendored
Normal file
@@ -0,0 +1,87 @@
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var Base = require('./base')
|
||||
, cursor = Base.cursor
|
||||
, color = Base.color;
|
||||
|
||||
/**
|
||||
* Expose `Spec`.
|
||||
*/
|
||||
|
||||
exports = module.exports = Spec;
|
||||
|
||||
/**
|
||||
* Initialize a new `Spec` test reporter.
|
||||
*
|
||||
* @param {Runner} runner
|
||||
* @api public
|
||||
*/
|
||||
|
||||
function Spec(runner) {
|
||||
Base.call(this, runner);
|
||||
|
||||
var self = this
|
||||
, stats = this.stats
|
||||
, indents = 0
|
||||
, 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(suite){
|
||||
--indents;
|
||||
if (1 == indents) console.log();
|
||||
});
|
||||
|
||||
runner.on('test', function(test){
|
||||
process.stdout.write(indent() + color('pass', ' ◦ ' + test.title + ': '));
|
||||
});
|
||||
|
||||
runner.on('pending', function(test){
|
||||
var fmt = indent() + color('pending', ' - %s');
|
||||
console.log(fmt, test.title);
|
||||
});
|
||||
|
||||
runner.on('pass', function(test){
|
||||
if ('fast' == test.speed) {
|
||||
var fmt = indent()
|
||||
+ color('checkmark', ' ✓')
|
||||
+ color('pass', ' %s ');
|
||||
cursor.CR();
|
||||
console.log(fmt, test.title);
|
||||
} else {
|
||||
var fmt = indent()
|
||||
+ color('checkmark', ' ✓')
|
||||
+ color('pass', ' %s ')
|
||||
+ color(test.speed, '(%dms)');
|
||||
cursor.CR();
|
||||
console.log(fmt, test.title, test.duration);
|
||||
}
|
||||
});
|
||||
|
||||
runner.on('fail', function(test, err){
|
||||
cursor.CR();
|
||||
console.log(indent() + color('fail', ' %d) %s'), ++n, test.title);
|
||||
});
|
||||
|
||||
runner.on('end', self.epilogue.bind(self));
|
||||
}
|
||||
|
||||
/**
|
||||
* Inherit from `Base.prototype`.
|
||||
*/
|
||||
|
||||
Spec.prototype.__proto__ = Base.prototype;
|
||||
63
node_modules/mocha/lib/reporters/tap.js
generated
vendored
Normal file
63
node_modules/mocha/lib/reporters/tap.js
generated
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var Base = require('./base')
|
||||
, cursor = Base.cursor
|
||||
, color = Base.color;
|
||||
|
||||
/**
|
||||
* Expose `TAP`.
|
||||
*/
|
||||
|
||||
exports = module.exports = TAP;
|
||||
|
||||
/**
|
||||
* Initialize a new `TAP` reporter.
|
||||
*
|
||||
* @param {Runner} runner
|
||||
* @api public
|
||||
*/
|
||||
|
||||
function TAP(runner) {
|
||||
Base.call(this, runner);
|
||||
|
||||
var self = this
|
||||
, stats = this.stats
|
||||
, total = runner.total
|
||||
, n = 1;
|
||||
|
||||
runner.on('start', function(){
|
||||
console.log('%d..%d', 1, total);
|
||||
});
|
||||
|
||||
runner.on('test end', function(){
|
||||
++n;
|
||||
});
|
||||
|
||||
runner.on('pending', function(test){
|
||||
console.log('ok %d %s # SKIP -', n, title(test));
|
||||
});
|
||||
|
||||
runner.on('pass', function(test){
|
||||
console.log('ok %d %s', n, title(test));
|
||||
});
|
||||
|
||||
runner.on('fail', function(test, err){
|
||||
console.log('not ok %d %s', n, title(test));
|
||||
console.log(err.stack.replace(/^/gm, ' '));
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a TAP-safe title of `test`
|
||||
*
|
||||
* @param {Object} test
|
||||
* @return {String}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function title(test) {
|
||||
return test.fullTitle().replace(/#/g, '');
|
||||
}
|
||||
56
node_modules/mocha/lib/reporters/teamcity.js
generated
vendored
Normal file
56
node_modules/mocha/lib/reporters/teamcity.js
generated
vendored
Normal file
@@ -0,0 +1,56 @@
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var Base = require('./base');
|
||||
|
||||
/**
|
||||
* Expose `Teamcity`.
|
||||
*/
|
||||
|
||||
exports = module.exports = Teamcity;
|
||||
|
||||
/**
|
||||
* Initialize a new `Teamcity` reporter.
|
||||
*
|
||||
* @param {Runner} runner
|
||||
* @api public
|
||||
*/
|
||||
|
||||
function Teamcity(runner) {
|
||||
Base.call(this, runner);
|
||||
var stats = this.stats;
|
||||
|
||||
runner.on('start', function() {
|
||||
console.log("##teamcity[testSuiteStarted name='mocha.suite']");
|
||||
});
|
||||
|
||||
runner.on('test', function(test) {
|
||||
console.log("##teamcity[testStarted name='%s']", escape(test.fullTitle()));
|
||||
});
|
||||
|
||||
runner.on('fail', function(test, err) {
|
||||
console.log("##teamcity[testFailed name='%s' message='%s']", escape(test.fullTitle()), escape(err.message));
|
||||
});
|
||||
|
||||
runner.on('pending', function(test) {
|
||||
console.log("##teamcity[testIgnored name='%s' message='pending']", escape(test.fullTitle()));
|
||||
});
|
||||
|
||||
runner.on('test end', function(test) {
|
||||
console.log("##teamcity[testFinished name='%s' duration='%s']", escape(test.fullTitle()), test.duration);
|
||||
});
|
||||
|
||||
runner.on('end', function() {
|
||||
console.log("##teamcity[testSuiteFinished name='mocha.suite' duration='%s']", stats.duration);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Escape the given `str`.
|
||||
*/
|
||||
|
||||
function escape(str) {
|
||||
return str.replace(/'/g, "|'");
|
||||
}
|
||||
101
node_modules/mocha/lib/reporters/xunit.js
generated
vendored
Normal file
101
node_modules/mocha/lib/reporters/xunit.js
generated
vendored
Normal file
@@ -0,0 +1,101 @@
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var Base = require('./base')
|
||||
, utils = require('../utils')
|
||||
, escape = utils.escape;
|
||||
|
||||
/**
|
||||
* Expose `XUnit`.
|
||||
*/
|
||||
|
||||
exports = module.exports = XUnit;
|
||||
|
||||
/**
|
||||
* Initialize a new `XUnit` reporter.
|
||||
*
|
||||
* @param {Runner} runner
|
||||
* @api public
|
||||
*/
|
||||
|
||||
function XUnit(runner) {
|
||||
Base.call(this, runner);
|
||||
var stats = this.stats
|
||||
, tests = []
|
||||
, self = this;
|
||||
|
||||
runner.on('test end', function(test){
|
||||
tests.push(test);
|
||||
});
|
||||
|
||||
runner.on('end', function(){
|
||||
console.log(tag('testsuite', {
|
||||
name: 'Mocha Tests'
|
||||
, tests: stats.tests
|
||||
, failures: stats.failures
|
||||
, errors: stats.failures
|
||||
, skip: stats.tests - stats.failures - stats.passes
|
||||
, timestamp: (new Date).toUTCString()
|
||||
, time: stats.duration / 1000
|
||||
}, false));
|
||||
|
||||
tests.forEach(test);
|
||||
console.log('</testsuite>');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Inherit from `Base.prototype`.
|
||||
*/
|
||||
|
||||
XUnit.prototype.__proto__ = Base.prototype;
|
||||
|
||||
/**
|
||||
* Output tag for the given `test.`
|
||||
*/
|
||||
|
||||
function test(test) {
|
||||
var attrs = {
|
||||
classname: test.parent.fullTitle()
|
||||
, name: test.title
|
||||
, time: test.duration / 1000
|
||||
};
|
||||
|
||||
if (test.failed) {
|
||||
var err = test.err;
|
||||
attrs.message = escape(err.message);
|
||||
console.log(tag('testcase', attrs, false, tag('failure', attrs, false, cdata(err.stack))));
|
||||
} else if (test.pending) {
|
||||
console.log(tag('testcase', attrs, false, tag('skipped', {}, true)));
|
||||
} else {
|
||||
console.log(tag('testcase', attrs, true) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* HTML tag helper.
|
||||
*/
|
||||
|
||||
function tag(name, attrs, close, content) {
|
||||
var end = close ? '/>' : '>'
|
||||
, pairs = []
|
||||
, tag;
|
||||
|
||||
for (var key in attrs) {
|
||||
pairs.push(key + '="' + escape(attrs[key]) + '"');
|
||||
}
|
||||
|
||||
tag = '<' + name + (pairs.length ? ' ' + pairs.join(' ') : '') + end;
|
||||
if (content) tag += content + '</' + name + end;
|
||||
return tag;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return cdata escaped CDATA `str`.
|
||||
*/
|
||||
|
||||
function cdata(str) {
|
||||
return '<![CDATA[' + escape(str) + ']]>';
|
||||
}
|
||||
Reference in New Issue
Block a user