Socket
Socket
Sign inDemoInstall

mocha

Package Overview
Dependencies
Maintainers
1
Versions
199
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mocha - npm Package Compare versions

Comparing version 5.1.1 to 5.2.0

22

bin/options.js

@@ -19,13 +19,19 @@ 'use strict';

function getOptions () {
if (process.argv.length === 3 && (process.argv[2] === '-h' || process.argv[2] === '--help')) {
function getOptions() {
if (
process.argv.length === 3 &&
(process.argv[2] === '-h' || process.argv[2] === '--help')
) {
return;
}
const optsPath = process.argv.indexOf('--opts') === -1
? 'test/mocha.opts'
: process.argv[process.argv.indexOf('--opts') + 1];
const optsPath =
process.argv.indexOf('--opts') === -1
? 'test/mocha.opts'
: process.argv[process.argv.indexOf('--opts') + 1];
try {
const opts = fs.readFileSync(optsPath, 'utf8')
const opts = fs
.readFileSync(optsPath, 'utf8')
.replace(/^#.*$/gm, '')
.replace(/\\\s/g, '%20')

@@ -39,4 +45,4 @@ .split(/\s/)

.concat(opts.concat(process.argv.slice(2)));
} catch (err) {
// ignore
} catch (ignore) {
// NOTE: should console.error() and throw the error
}

@@ -43,0 +49,0 @@

@@ -20,3 +20,3 @@ 'use strict';

var mocha = new Mocha({ reporter: 'html' });
var mocha = new Mocha({reporter: 'html'});

@@ -42,3 +42,3 @@ /**

process.removeListener = function (e, fn) {
process.removeListener = function(e, fn) {
if (e === 'uncaughtException') {

@@ -48,3 +48,3 @@ if (originalOnerrorHandler) {

} else {
global.onerror = function () {};
global.onerror = function() {};
}

@@ -62,5 +62,5 @@ var i = uncaughtExceptionHandlers.indexOf(fn);

process.on = function (e, fn) {
process.on = function(e, fn) {
if (e === 'uncaughtException') {
global.onerror = function (err, url, line) {
global.onerror = function(err, url, line) {
fn(new Error(err + ' (' + url + ':' + line + ')'));

@@ -81,5 +81,5 @@ return !mocha.allowUncaught;

function timeslice () {
function timeslice() {
var immediateStart = new Date().getTime();
while (immediateQueue.length && (new Date().getTime() - immediateStart) < 100) {
while (immediateQueue.length && new Date().getTime() - immediateStart < 100) {
immediateQueue.shift()();

@@ -98,3 +98,3 @@ }

Mocha.Runner.immediately = function (callback) {
Mocha.Runner.immediately = function(callback) {
immediateQueue.push(callback);

@@ -111,4 +111,4 @@ if (!immediateTimeout) {

*/
mocha.throwError = function (err) {
uncaughtExceptionHandlers.forEach(function (fn) {
mocha.throwError = function(err) {
uncaughtExceptionHandlers.forEach(function(fn) {
fn(err);

@@ -124,3 +124,3 @@ });

mocha.ui = function (ui) {
mocha.ui = function(ui) {
Mocha.prototype.ui.call(this, ui);

@@ -135,5 +135,5 @@ this.suite.emit('pre-require', global, null, this);

mocha.setup = function (opts) {
mocha.setup = function(opts) {
if (typeof opts === 'string') {
opts = { ui: opts };
opts = {ui: opts};
}

@@ -152,3 +152,3 @@ for (var opt in opts) {

mocha.run = function (fn) {
mocha.run = function(fn) {
var options = mocha.options;

@@ -168,6 +168,10 @@ mocha.globals('location');

return Mocha.prototype.run.call(mocha, function (err) {
return Mocha.prototype.run.call(mocha, function(err) {
// The DOM Document is not available in Web Workers.
var document = global.document;
if (document && document.getElementById('mocha') && options.noHighlighting !== true) {
if (
document &&
document.getElementById('mocha') &&
options.noHighlighting !== true
) {
Mocha.utils.highlightTags('code');

@@ -174,0 +178,0 @@ }

@@ -12,3 +12,3 @@ 'use strict';

*/
function Progress () {
function Progress() {
this.percent = 0;

@@ -27,3 +27,3 @@ this.size(0);

*/
Progress.prototype.size = function (size) {
Progress.prototype.size = function(size) {
this._size = size;

@@ -40,3 +40,3 @@ return this;

*/
Progress.prototype.text = function (text) {
Progress.prototype.text = function(text) {
this._text = text;

@@ -53,3 +53,3 @@ return this;

*/
Progress.prototype.fontSize = function (size) {
Progress.prototype.fontSize = function(size) {
this._fontSize = size;

@@ -65,3 +65,3 @@ return this;

*/
Progress.prototype.font = function (family) {
Progress.prototype.font = function(family) {
this._font = family;

@@ -77,3 +77,3 @@ return this;

*/
Progress.prototype.update = function (n) {
Progress.prototype.update = function(n) {
this.percent = n;

@@ -89,3 +89,3 @@ return this;

*/
Progress.prototype.draw = function (ctx) {
Progress.prototype.draw = function(ctx) {
try {

@@ -122,3 +122,3 @@ var percent = Math.min(this.percent, 100);

ctx.fillText(text, x - w / 2 + 1, y + fontSize / 2 - 1);
} catch (err) {
} catch (ignore) {
// don't fail if we can't render progress

@@ -125,0 +125,0 @@ }

'use strict';
exports.isatty = function isatty () {
exports.isatty = function isatty() {
return true;
};
exports.getWindowSize = function getWindowSize () {
exports.getWindowSize = function getWindowSize() {
if ('innerHeight' in global) {

@@ -9,0 +9,0 @@ return [global.innerHeight, global.innerWidth];

@@ -16,3 +16,3 @@ 'use strict';

*/
function Context () {}
function Context() {}

@@ -26,3 +26,3 @@ /**

*/
Context.prototype.runnable = function (runnable) {
Context.prototype.runnable = function(runnable) {
if (!arguments.length) {

@@ -42,3 +42,3 @@ return this._runnable;

*/
Context.prototype.timeout = function (ms) {
Context.prototype.timeout = function(ms) {
if (!arguments.length) {

@@ -58,3 +58,3 @@ return this.runnable().timeout();

*/
Context.prototype.enableTimeouts = function (enabled) {
Context.prototype.enableTimeouts = function(enabled) {
if (!arguments.length) {

@@ -74,3 +74,3 @@ return this.runnable().enableTimeouts();

*/
Context.prototype.slow = function (ms) {
Context.prototype.slow = function(ms) {
if (!arguments.length) {

@@ -89,3 +89,3 @@ return this.runnable().slow();

*/
Context.prototype.skip = function () {
Context.prototype.skip = function() {
this.runnable().skip();

@@ -101,3 +101,3 @@ };

*/
Context.prototype.retries = function (n) {
Context.prototype.retries = function(n) {
if (!arguments.length) {

@@ -104,0 +104,0 @@ return this.runnable().retries();

'use strict';
/**
* @module Hook
*
*/
/**
* Module dependencies.
*/

@@ -20,13 +13,10 @@ var Runnable = require('./runnable');

/**
* Initialize a new `Hook` with the given `title` and callback `fn`. Derived from
* `Runnable`.
* Initialize a new `Hook` with the given `title` and callback `fn`
*
* @memberof Mocha
* @public
* @class
* @extends Runnable
* @param {String} title
* @param {Function} fn
* @api private
*/
function Hook (title, fn) {
function Hook(title, fn) {
Runnable.call(this, title, fn);

@@ -44,9 +34,8 @@ this.type = 'hook';

*
* @memberof Mocha.Hook
* @memberof Hook
* @public
* @param {Error} err
* @return {Error}
* @api public
*/
Hook.prototype.error = function (err) {
Hook.prototype.error = function(err) {
if (!arguments.length) {

@@ -53,0 +42,0 @@ err = this._error;

'use strict';
/**
* Module dependencies.
*/
var Test = require('../test');

@@ -26,6 +22,6 @@

*/
module.exports = function (suite) {
module.exports = function bddInterface(suite) {
var suites = [suite];
suite.on('pre-require', function (context, file, mocha) {
suite.on('pre-require', function(context, file, mocha) {
var common = require('./common')(suites, context, mocha);

@@ -44,3 +40,3 @@

context.describe = context.context = function (title, fn) {
context.describe = context.context = function(title, fn) {
return common.suite.create({

@@ -57,3 +53,6 @@ title: title,

context.xdescribe = context.xcontext = context.describe.skip = function (title, fn) {
context.xdescribe = context.xcontext = context.describe.skip = function(
title,
fn
) {
return common.suite.skip({

@@ -70,3 +69,3 @@ title: title,

context.describe.only = function (title, fn) {
context.describe.only = function(title, fn) {
return common.suite.only({

@@ -85,3 +84,3 @@ title: title,

context.it = context.specify = function (title, fn) {
context.it = context.specify = function(title, fn) {
var suite = suites[0];

@@ -101,3 +100,3 @@ if (suite.isPending()) {

context.it.only = function (title, fn) {
context.it.only = function(title, fn) {
return common.test.only(mocha, context.it(title, fn));

@@ -110,3 +109,3 @@ };

context.xit = context.xspecify = context.it.skip = function (title) {
context.xit = context.xspecify = context.it.skip = function(title) {
return context.it(title);

@@ -118,3 +117,3 @@ };

*/
context.it.retries = function (n) {
context.it.retries = function(n) {
context.retries(n);

@@ -121,0 +120,0 @@ };

@@ -13,3 +13,3 @@ 'use strict';

*/
module.exports = function (suites, context, mocha) {
module.exports = function(suites, context, mocha) {
return {

@@ -23,4 +23,4 @@ /**

*/
runWithSuite: function runWithSuite (suite) {
return function run () {
runWithSuite: function runWithSuite(suite) {
return function run() {
suite.run();

@@ -36,3 +36,3 @@ };

*/
before: function (name, fn) {
before: function(name, fn) {
suites[0].beforeAll(name, fn);

@@ -47,3 +47,3 @@ },

*/
after: function (name, fn) {
after: function(name, fn) {
suites[0].afterAll(name, fn);

@@ -58,3 +58,3 @@ },

*/
beforeEach: function (name, fn) {
beforeEach: function(name, fn) {
suites[0].beforeEach(name, fn);

@@ -69,3 +69,3 @@ },

*/
afterEach: function (name, fn) {
afterEach: function(name, fn) {
suites[0].afterEach(name, fn);

@@ -82,3 +82,3 @@ },

*/
only: function only (opts) {
only: function only(opts) {
opts.isOnly = true;

@@ -95,3 +95,3 @@ return this.create(opts);

*/
skip: function skip (opts) {
skip: function skip(opts) {
opts.pending = true;

@@ -111,3 +111,3 @@ return this.create(opts);

*/
create: function create (opts) {
create: function create(opts) {
var suite = Suite.create(suites[0], opts.title);

@@ -124,3 +124,7 @@ suite.pending = Boolean(opts.pending);

} else if (typeof opts.fn === 'undefined' && !suite.pending) {
throw new Error('Suite "' + suite.fullTitle() + '" was defined but no callback was supplied. Supply a callback or explicitly skip the suite.');
throw new Error(
'Suite "' +
suite.fullTitle() +
'" was defined but no callback was supplied. Supply a callback or explicitly skip the suite.'
);
} else if (!opts.fn && suite.pending) {

@@ -135,3 +139,2 @@ suites.shift();

test: {
/**

@@ -144,3 +147,3 @@ * Exclusive test-case.

*/
only: function (mocha, test) {
only: function(mocha, test) {
test.parent._onlyTests = test.parent._onlyTests.concat(test);

@@ -155,3 +158,3 @@ return test;

*/
skip: function (title) {
skip: function(title) {
context.test(title);

@@ -165,3 +168,3 @@ },

*/
retries: function (n) {
retries: function(n) {
context.retries(n);

@@ -168,0 +171,0 @@ }

'use strict';
/**
* Module dependencies.
*/
var Suite = require('../suite');

@@ -27,3 +22,3 @@ var Test = require('../test');

*/
module.exports = function (suite) {
module.exports = function(suite) {
var suites = [suite];

@@ -33,3 +28,3 @@

function visit (obj, file) {
function visit(obj, file) {
var suite;

@@ -36,0 +31,0 @@ for (var key in obj) {

'use strict';
/**
* Module dependencies.
*/
var Test = require('../test');

@@ -34,6 +30,6 @@

*/
module.exports = function (suite) {
module.exports = function qUnitInterface(suite) {
var suites = [suite];
suite.on('pre-require', function (context, file, mocha) {
suite.on('pre-require', function(context, file, mocha) {
var common = require('./common')(suites, context, mocha);

@@ -50,3 +46,3 @@

context.suite = function (title) {
context.suite = function(title) {
if (suites.length > 1) {

@@ -66,3 +62,3 @@ suites.shift();

context.suite.only = function (title) {
context.suite.only = function(title) {
if (suites.length > 1) {

@@ -84,3 +80,3 @@ suites.shift();

context.test = function (title, fn) {
context.test = function(title, fn) {
var test = new Test(title, fn);

@@ -96,3 +92,3 @@ test.file = file;

context.test.only = function (title, fn) {
context.test.only = function(title, fn) {
return common.test.only(mocha, context.test(title, fn));

@@ -99,0 +95,0 @@ };

'use strict';
/**
* Module dependencies.
*/
var Test = require('../test');

@@ -34,6 +30,6 @@

*/
module.exports = function (suite) {
module.exports = function(suite) {
var suites = [suite];
suite.on('pre-require', function (context, file, mocha) {
suite.on('pre-require', function(context, file, mocha) {
var common = require('./common')(suites, context, mocha);

@@ -51,3 +47,3 @@

*/
context.suite = function (title, fn) {
context.suite = function(title, fn) {
return common.suite.create({

@@ -63,3 +59,3 @@ title: title,

*/
context.suite.skip = function (title, fn) {
context.suite.skip = function(title, fn) {
return common.suite.skip({

@@ -75,3 +71,3 @@ title: title,

*/
context.suite.only = function (title, fn) {
context.suite.only = function(title, fn) {
return common.suite.only({

@@ -88,3 +84,3 @@ title: title,

*/
context.test = function (title, fn) {
context.test = function(title, fn) {
var suite = suites[0];

@@ -104,3 +100,3 @@ if (suite.isPending()) {

context.test.only = function (title, fn) {
context.test.only = function(title, fn) {
return common.test.only(mocha, context.test(title, fn));

@@ -107,0 +103,0 @@ };

@@ -8,9 +8,2 @@ 'use strict';

*/
/**
* @namespace Mocha
* @module Mocha
*/
/**
* Module dependencies.
*/

@@ -22,6 +15,2 @@ var escapeRe = require('escape-string-regexp');

/**
* Expose `Mocha`.
*/
exports = module.exports = Mocha;

@@ -69,8 +58,8 @@

*
* @api private
* @private
* @param {string} name
* @return {string}
*/
function image (name) {
return path.join(__dirname, '../images', name + '.png');
function image(name) {
return path.join(__dirname, '..', 'assets', 'growl', name + '.png');
}

@@ -94,8 +83,6 @@

*
* @public
* @class Mocha
* @param {Object} options
* @api public
*/
function Mocha (options) {
function Mocha(options) {
options = options || {};

@@ -136,3 +123,3 @@ this.files = [];

*/
Mocha.prototype.bail = function (bail) {
Mocha.prototype.bail = function(bail) {
if (!arguments.length) {

@@ -152,3 +139,3 @@ bail = true;

*/
Mocha.prototype.addFile = function (file) {
Mocha.prototype.addFile = function(file) {
this.files.push(file);

@@ -168,3 +155,3 @@ return this;

*/
Mocha.prototype.reporter = function (reporter, reporterOptions) {
Mocha.prototype.reporter = function(reporter, reporterOptions) {
if (typeof reporter === 'function') {

@@ -189,7 +176,15 @@ this._reporter = reporter;

} catch (_err) {
err.message.indexOf('Cannot find module') !== -1 ? console.warn('"' + reporter + '" reporter not found')
: console.warn('"' + reporter + '" reporter blew up with error:\n' + err.stack);
err.message.indexOf('Cannot find module') !== -1
? console.warn('"' + reporter + '" reporter not found')
: console.warn(
'"' +
reporter +
'" reporter blew up with error:\n' +
err.stack
);
}
} else {
console.warn('"' + reporter + '" reporter blew up with error:\n' + err.stack);
console.warn(
'"' + reporter + '" reporter blew up with error:\n' + err.stack
);
}

@@ -199,5 +194,7 @@ }

if (!_reporter && reporter === 'teamcity') {
console.warn('The Teamcity reporter was moved to a package named ' +
'mocha-teamcity-reporter ' +
'(https://npmjs.org/package/mocha-teamcity-reporter).');
console.warn(
'The Teamcity reporter was moved to a package named ' +
'mocha-teamcity-reporter ' +
'(https://npmjs.org/package/mocha-teamcity-reporter).'
);
}

@@ -219,3 +216,3 @@ if (!_reporter) {

*/
Mocha.prototype.ui = function (name) {
Mocha.prototype.ui = function(name) {
name = name || 'bdd';

@@ -232,3 +229,3 @@ this._ui = exports.interfaces[name];

this.suite.on('pre-require', function (context) {
this.suite.on('pre-require', function(context) {
exports.afterEach = context.afterEach || context.teardown;

@@ -258,6 +255,6 @@ exports.after = context.after || context.suiteTeardown;

*/
Mocha.prototype.loadFiles = function (fn) {
Mocha.prototype.loadFiles = function(fn) {
var self = this;
var suite = this.suite;
this.files.forEach(function (file) {
this.files.forEach(function(file) {
file = path.resolve(file);

@@ -276,10 +273,10 @@ suite.emit('pre-require', global, file, self);

*/
Mocha.prototype._growl = function (runner, reporter) {
Mocha.prototype._growl = function(runner, reporter) {
var notify = require('growl');
runner.on('end', function () {
runner.on('end', function() {
var stats = reporter.stats;
if (stats.failures) {
var msg = stats.failures + ' of ' + runner.total + ' tests failed';
notify(msg, { name: 'mocha', title: 'Failed', image: image('error') });
notify(msg, {name: 'mocha', title: 'Failed', image: image('error')});
} else {

@@ -303,3 +300,3 @@ notify(stats.passes + ' tests passed in ' + stats.duration + 'ms', {

*/
Mocha.prototype.fgrep = function (str) {
Mocha.prototype.fgrep = function(str) {
return this.grep(new RegExp(escapeRe(str)));

@@ -318,3 +315,3 @@ };

*/
Mocha.prototype.grep = function (re) {
Mocha.prototype.grep = function(re) {
if (utils.isString(re)) {

@@ -336,3 +333,3 @@ // extract args if it's regex-like, i.e: [string, pattern, flag]

*/
Mocha.prototype.invert = function () {
Mocha.prototype.invert = function() {
this.options.invert = true;

@@ -352,3 +349,3 @@ return this;

*/
Mocha.prototype.ignoreLeaks = function (ignore) {
Mocha.prototype.ignoreLeaks = function(ignore) {
this.options.ignoreLeaks = Boolean(ignore);

@@ -365,3 +362,3 @@ return this;

*/
Mocha.prototype.checkLeaks = function () {
Mocha.prototype.checkLeaks = function() {
this.options.ignoreLeaks = false;

@@ -378,3 +375,3 @@ return this;

*/
Mocha.prototype.fullTrace = function () {
Mocha.prototype.fullTrace = function() {
this.options.fullStackTrace = true;

@@ -391,3 +388,3 @@ return this;

*/
Mocha.prototype.growl = function () {
Mocha.prototype.growl = function() {
this.options.growl = true;

@@ -407,3 +404,3 @@ return this;

*/
Mocha.prototype.globals = function (globals) {
Mocha.prototype.globals = function(globals) {
this.options.globals = (this.options.globals || []).concat(globals);

@@ -423,3 +420,3 @@ return this;

*/
Mocha.prototype.useColors = function (colors) {
Mocha.prototype.useColors = function(colors) {
if (colors !== undefined) {

@@ -441,3 +438,3 @@ this.options.useColors = colors;

*/
Mocha.prototype.useInlineDiffs = function (inlineDiffs) {
Mocha.prototype.useInlineDiffs = function(inlineDiffs) {
this.options.useInlineDiffs = inlineDiffs !== undefined && inlineDiffs;

@@ -457,3 +454,3 @@ return this;

*/
Mocha.prototype.hideDiff = function (hideDiff) {
Mocha.prototype.hideDiff = function(hideDiff) {
this.options.hideDiff = hideDiff !== undefined && hideDiff;

@@ -473,3 +470,3 @@ return this;

*/
Mocha.prototype.timeout = function (timeout) {
Mocha.prototype.timeout = function(timeout) {
this.suite.timeout(timeout);

@@ -487,3 +484,3 @@ return this;

*/
Mocha.prototype.retries = function (n) {
Mocha.prototype.retries = function(n) {
this.suite.retries(n);

@@ -503,3 +500,3 @@ return this;

*/
Mocha.prototype.slow = function (slow) {
Mocha.prototype.slow = function(slow) {
this.suite.slow(slow);

@@ -519,4 +516,6 @@ return this;

*/
Mocha.prototype.enableTimeouts = function (enabled) {
this.suite.enableTimeouts(arguments.length && enabled !== undefined ? enabled : true);
Mocha.prototype.enableTimeouts = function(enabled) {
this.suite.enableTimeouts(
arguments.length && enabled !== undefined ? enabled : true
);
return this;

@@ -532,3 +531,3 @@ };

*/
Mocha.prototype.asyncOnly = function () {
Mocha.prototype.asyncOnly = function() {
this.options.asyncOnly = true;

@@ -544,3 +543,3 @@ return this;

*/
Mocha.prototype.noHighlighting = function () {
Mocha.prototype.noHighlighting = function() {
this.options.noHighlighting = true;

@@ -557,3 +556,3 @@ return this;

*/
Mocha.prototype.allowUncaught = function () {
Mocha.prototype.allowUncaught = function() {
this.options.allowUncaught = true;

@@ -567,3 +566,3 @@ return this;

*/
Mocha.prototype.delay = function delay () {
Mocha.prototype.delay = function delay() {
this.options.delay = true;

@@ -577,3 +576,3 @@ return this;

*/
Mocha.prototype.forbidOnly = function () {
Mocha.prototype.forbidOnly = function() {
this.options.forbidOnly = true;

@@ -587,3 +586,3 @@ return this;

*/
Mocha.prototype.forbidPending = function () {
Mocha.prototype.forbidPending = function() {
this.options.forbidPending = true;

@@ -609,3 +608,3 @@ return this;

*/
Mocha.prototype.run = function (fn) {
Mocha.prototype.run = function(fn) {
if (this.files.length) {

@@ -640,3 +639,3 @@ this.loadFiles();

function done (failures) {
function done(failures) {
if (reporter.done) {

@@ -643,0 +642,0 @@ reporter.done(failures, fn);

@@ -24,3 +24,3 @@ 'use strict';

*/
module.exports = function (val) {
module.exports = function(val) {
if (typeof val === 'string') {

@@ -39,4 +39,6 @@ return parse(val);

*/
function parse (str) {
var match = (/^((?:\d+)?\.?\d+) *(ms|seconds?|s|minutes?|m|hours?|h|days?|d|years?|y)?$/i).exec(str);
function parse(str) {
var match = /^((?:\d+)?\.?\d+) *(ms|seconds?|s|minutes?|m|hours?|h|days?|d|years?|y)?$/i.exec(
str
);
if (!match) {

@@ -71,3 +73,3 @@ return;

default:
// No default case
// No default case
}

@@ -83,3 +85,3 @@ }

*/
function format (ms) {
function format(ms) {
if (ms >= d) {

@@ -86,0 +88,0 @@ return Math.round(ms / d) + 'd';

'use strict';
/**
* Expose `Pending`.
*/
module.exports = Pending;

@@ -14,4 +10,4 @@

*/
function Pending (message) {
function Pending(message) {
this.message = message;
}

@@ -44,3 +44,5 @@ 'use strict';

exports.useColors = !process.browser && (supportsColor || (process.env.MOCHA_COLORS !== undefined));
exports.useColors =
!process.browser &&
(supportsColor.stdout || process.env.MOCHA_COLORS !== undefined);

@@ -109,3 +111,3 @@ /**

*/
var color = exports.color = function (type, str) {
var color = (exports.color = function(type, str) {
if (!exports.useColors) {

@@ -115,3 +117,3 @@ return String(str);

return '\u001b[' + exports.colors[type] + 'm' + str + '\u001b[0m';
};
});

@@ -137,19 +139,19 @@ /**

exports.cursor = {
hide: function () {
hide: function() {
isatty && process.stdout.write('\u001b[?25l');
},
show: function () {
show: function() {
isatty && process.stdout.write('\u001b[?25h');
},
deleteLine: function () {
deleteLine: function() {
isatty && process.stdout.write('\u001b[2K');
},
beginningOfLine: function () {
beginningOfLine: function() {
isatty && process.stdout.write('\u001b[0G');
},
CR: function () {
CR: function() {
if (isatty) {

@@ -164,7 +166,12 @@ exports.cursor.deleteLine();

function showDiff (err) {
return err && err.showDiff !== false && sameType(err.actual, err.expected) && err.expected !== undefined;
function showDiff(err) {
return (
err &&
err.showDiff !== false &&
sameType(err.actual, err.expected) &&
err.expected !== undefined
);
}
function stringifyDiffObjs (err) {
function stringifyDiffObjs(err) {
if (!utils.isString(err.actual) || !utils.isString(err.expected)) {

@@ -186,7 +193,7 @@ err.actual = utils.stringify(err.actual);

*/
var generateDiff = exports.generateDiff = function (actual, expected) {
var generateDiff = (exports.generateDiff = function(actual, expected) {
return exports.inlineDiffs
? inlineDiff(actual, expected)
: unifiedDiff(actual, expected);
};
});

@@ -203,7 +210,8 @@ /**

exports.list = function (failures) {
exports.list = function(failures) {
console.log();
failures.forEach(function (test, i) {
failures.forEach(function(test, i) {
// format
var fmt = color('error title', ' %s) %s:\n') +
var fmt =
color('error title', ' %s) %s:\n') +
color('error message', ' %s') +

@@ -242,3 +250,4 @@ color('error stack', '\n%s\n');

stringifyDiffObjs(err);
fmt = color('error title', ' %s) %s:\n%s') + color('error stack', '\n%s\n');
fmt =
color('error title', ' %s) %s:\n%s') + color('error stack', '\n%s\n');
var match = message.match(/^([^:]+): expected/);

@@ -255,3 +264,3 @@ msg = '\n ' + color('error message', match ? match[1] : msg);

var testTitle = '';
test.titlePath().forEach(function (str, index) {
test.titlePath().forEach(function(str, index) {
if (index !== 0) {

@@ -266,3 +275,3 @@ testTitle += '\n ';

console.log(fmt, (i + 1), testTitle, msg, stack);
console.log(fmt, i + 1, testTitle, msg, stack);
});

@@ -286,5 +295,11 @@ };

function Base (runner) {
var stats = this.stats = { suites: 0, tests: 0, passes: 0, pending: 0, failures: 0 };
var failures = this.failures = [];
function Base(runner) {
var stats = (this.stats = {
suites: 0,
tests: 0,
passes: 0,
pending: 0,
failures: 0
});
var failures = (this.failures = []);

@@ -298,7 +313,7 @@ if (!runner) {

runner.on('start', function () {
runner.on('start', function() {
stats.start = new Date();
});
runner.on('suite', function (suite) {
runner.on('suite', function(suite) {
stats.suites = stats.suites || 0;

@@ -308,3 +323,3 @@ suite.root || stats.suites++;

runner.on('test end', function () {
runner.on('test end', function() {
stats.tests = stats.tests || 0;

@@ -314,3 +329,3 @@ stats.tests++;

runner.on('pass', function (test) {
runner.on('pass', function(test) {
stats.passes = stats.passes || 0;

@@ -329,3 +344,3 @@

runner.on('fail', function (test, err) {
runner.on('fail', function(test, err) {
stats.failures = stats.failures || 0;

@@ -340,3 +355,3 @@ stats.failures++;

runner.once('end', function () {
runner.once('end', function() {
stats.end = new Date();

@@ -346,3 +361,3 @@ stats.duration = stats.end - stats.start;

runner.on('pending', function () {
runner.on('pending', function() {
stats.pending++;

@@ -360,3 +375,3 @@ });

*/
Base.prototype.epilogue = function () {
Base.prototype.epilogue = function() {
var stats = this.stats;

@@ -368,14 +383,12 @@ var fmt;

// passes
fmt = color('bright pass', ' ') +
fmt =
color('bright pass', ' ') +
color('green', ' %d passing') +
color('light', ' (%s)');
console.log(fmt,
stats.passes || 0,
ms(stats.duration));
console.log(fmt, stats.passes || 0, ms(stats.duration));
// pending
if (stats.pending) {
fmt = color('pending', ' ') +
color('pending', ' %d pending');
fmt = color('pending', ' ') + color('pending', ' %d pending');

@@ -406,3 +419,3 @@ console.log(fmt, stats.pending);

*/
function pad (str, len) {
function pad(str, len) {
str = String(str);

@@ -420,3 +433,3 @@ return Array(len - str.length + 1).join(' ') + str;

*/
function inlineDiff (actual, expected) {
function inlineDiff(actual, expected) {
var msg = errorDiff(actual, expected);

@@ -428,9 +441,12 @@

var width = String(lines.length).length;
msg = lines.map(function (str, i) {
return pad(++i, width) + ' |' + ' ' + str;
}).join('\n');
msg = lines
.map(function(str, i) {
return pad(++i, width) + ' |' + ' ' + str;
})
.join('\n');
}
// legend
msg = '\n' +
msg =
'\n' +
color('diff removed', 'actual') +

@@ -456,5 +472,5 @@ ' ' +

*/
function unifiedDiff (actual, expected) {
function unifiedDiff(actual, expected) {
var indent = ' ';
function cleanUp (line) {
function cleanUp(line) {
if (line[0] === '+') {

@@ -474,3 +490,3 @@ return indent + colorLines('diff added', line);

}
function notBlank (line) {
function notBlank(line) {
return typeof line !== 'undefined' && line !== null;

@@ -480,7 +496,13 @@ }

var lines = msg.split('\n').splice(5);
return '\n ' +
colorLines('diff added', '+ expected') + ' ' +
return (
'\n ' +
colorLines('diff added', '+ expected') +
' ' +
colorLines('diff removed', '- actual') +
'\n\n' +
lines.map(cleanUp).filter(notBlank).join('\n');
lines
.map(cleanUp)
.filter(notBlank)
.join('\n')
);
}

@@ -496,12 +518,15 @@

*/
function errorDiff (actual, expected) {
return diff.diffWordsWithSpace(actual, expected).map(function (str) {
if (str.added) {
return colorLines('diff added', str.value);
}
if (str.removed) {
return colorLines('diff removed', str.value);
}
return str.value;
}).join('');
function errorDiff(actual, expected) {
return diff
.diffWordsWithSpace(actual, expected)
.map(function(str) {
if (str.added) {
return colorLines('diff added', str.value);
}
if (str.removed) {
return colorLines('diff removed', str.value);
}
return str.value;
})
.join('');
}

@@ -517,6 +542,9 @@

*/
function colorLines (name, str) {
return str.split('\n').map(function (str) {
return color(name, str);
}).join('\n');
function colorLines(name, str) {
return str
.split('\n')
.map(function(str) {
return color(name, str);
})
.join('\n');
}

@@ -537,4 +565,4 @@

*/
function sameType (a, b) {
function sameType(a, b) {
return objToString.call(a) === objToString.call(b);
}

@@ -28,3 +28,3 @@ 'use strict';

*/
function Doc (runner) {
function Doc(runner) {
Base.call(this, runner);

@@ -34,7 +34,7 @@

function indent () {
function indent() {
return Array(indents).join(' ');
}
runner.on('suite', function (suite) {
runner.on('suite', function(suite) {
if (suite.root) {

@@ -50,3 +50,3 @@ return;

runner.on('suite end', function (suite) {
runner.on('suite end', function(suite) {
if (suite.root) {

@@ -61,3 +61,3 @@ return;

runner.on('pass', function (test) {
runner.on('pass', function(test) {
console.log('%s <dt>%s</dt>', indent(), utils.escape(test.title));

@@ -68,8 +68,16 @@ var code = utils.escape(utils.clean(test.body));

runner.on('fail', function (test, err) {
console.log('%s <dt class="error">%s</dt>', indent(), utils.escape(test.title));
runner.on('fail', function(test, err) {
console.log(
'%s <dt class="error">%s</dt>',
indent(),
utils.escape(test.title)
);
var code = utils.escape(utils.clean(test.body));
console.log('%s <dd class="error"><pre><code>%s</code></pre></dd>', indent(), code);
console.log(
'%s <dd class="error"><pre><code>%s</code></pre></dd>',
indent(),
code
);
console.log('%s <dd class="error">%s</dd>', indent(), utils.escape(err));
});
}

@@ -29,14 +29,14 @@ 'use strict';

*/
function Dot (runner) {
function Dot(runner) {
Base.call(this, runner);
var self = this;
var width = Base.window.width * 0.75 | 0;
var width = (Base.window.width * 0.75) | 0;
var n = -1;
runner.on('start', function () {
runner.on('start', function() {
process.stdout.write('\n');
});
runner.on('pending', function () {
runner.on('pending', function() {
if (++n % width === 0) {

@@ -48,3 +48,3 @@ process.stdout.write('\n ');

runner.on('pass', function (test) {
runner.on('pass', function(test) {
if (++n % width === 0) {

@@ -60,3 +60,3 @@ process.stdout.write('\n ');

runner.on('fail', function () {
runner.on('fail', function() {
if (++n % width === 0) {

@@ -68,3 +68,3 @@ process.stdout.write('\n ');

runner.once('end', function () {
runner.once('end', function() {
console.log();

@@ -71,0 +71,0 @@ self.epilogue();

@@ -39,3 +39,4 @@ 'use strict';

var statsTemplate = '<ul id="mocha-stats">' +
var statsTemplate =
'<ul id="mocha-stats">' +
'<li class="progress"><canvas width="40" height="40"></canvas></li>' +

@@ -59,3 +60,3 @@ '<li class="passes"><a href="javascript:void(0);">passes:</a> <em>0</em></li>' +

*/
function HTML (runner) {
function HTML(runner) {
Base.call(this, runner);

@@ -95,6 +96,6 @@

// pass toggle
on(passesLink, 'click', function (evt) {
on(passesLink, 'click', function(evt) {
evt.preventDefault();
unhide();
var name = (/pass/).test(report.className) ? '' : ' pass';
var name = /pass/.test(report.className) ? '' : ' pass';
report.className = report.className.replace(/fail|pass/g, '') + name;

@@ -107,6 +108,6 @@ if (report.className.trim()) {

// failure toggle
on(failuresLink, 'click', function (evt) {
on(failuresLink, 'click', function(evt) {
evt.preventDefault();
unhide();
var name = (/fail/).test(report.className) ? '' : ' fail';
var name = /fail/.test(report.className) ? '' : ' fail';
report.className = report.className.replace(/fail|pass/g, '') + name;

@@ -125,3 +126,3 @@ if (report.className.trim()) {

runner.on('suite', function (suite) {
runner.on('suite', function(suite) {
if (suite.root) {

@@ -133,3 +134,7 @@ return;

var url = self.suiteURL(suite);
var el = fragment('<li class="suite"><h1><a href="%s">%s</a></h1></li>', url, escape(suite.title));
var el = fragment(
'<li class="suite"><h1><a href="%s">%s</a></h1></li>',
url,
escape(suite.title)
);

@@ -142,3 +147,3 @@ // container

runner.on('suite end', function (suite) {
runner.on('suite end', function(suite) {
if (suite.root) {

@@ -151,6 +156,9 @@ updateStats();

runner.on('pass', function (test) {
runner.on('pass', function(test) {
var url = self.testURL(test);
var markup = '<li class="test pass %e"><h2>%e<span class="duration">%ems</span> ' +
'<a href="%s" class="replay">' + playIcon + '</a></h2></li>';
var markup =
'<li class="test pass %e"><h2>%e<span class="duration">%ems</span> ' +
'<a href="%s" class="replay">' +
playIcon +
'</a></h2></li>';
var el = fragment(markup, test.speed, test.title, test.duration, url);

@@ -162,5 +170,10 @@ self.addCodeToggle(el, test.body);

runner.on('fail', function (test) {
var el = fragment('<li class="test fail"><h2>%e <a href="%e" class="replay">' + playIcon + '</a></h2></li>',
test.title, self.testURL(test));
runner.on('fail', function(test) {
var el = fragment(
'<li class="test fail"><h2>%e <a href="%e" class="replay">' +
playIcon +
'</a></h2></li>',
test.title,
self.testURL(test)
);
var stackString; // Note: Includes leading newline

@@ -180,3 +193,5 @@ var message = test.err.toString();

} else {
stackString = test.err.stack.substr(test.err.message.length + indexOfMessage);
stackString = test.err.stack.substr(
test.err.message.length + indexOfMessage
);
}

@@ -191,8 +206,17 @@ } else if (test.err.sourceURL && test.err.line !== undefined) {

if (test.err.htmlMessage && stackString) {
el.appendChild(fragment('<div class="html-error">%s\n<pre class="error">%e</pre></div>',
test.err.htmlMessage, stackString));
el.appendChild(
fragment(
'<div class="html-error">%s\n<pre class="error">%e</pre></div>',
test.err.htmlMessage,
stackString
)
);
} else if (test.err.htmlMessage) {
el.appendChild(fragment('<div class="html-error">%s</div>', test.err.htmlMessage));
el.appendChild(
fragment('<div class="html-error">%s</div>', test.err.htmlMessage)
);
} else {
el.appendChild(fragment('<pre class="error">%e%e</pre>', message, stackString));
el.appendChild(
fragment('<pre class="error">%e%e</pre>', message, stackString)
);
}

@@ -205,4 +229,7 @@

runner.on('pending', function (test) {
var el = fragment('<li class="test pass pending"><h2>%e</h2></li>', test.title);
runner.on('pending', function(test) {
var el = fragment(
'<li class="test pass pending"><h2>%e</h2></li>',
test.title
);
appendToStack(el);

@@ -212,3 +239,3 @@ updateStats();

function appendToStack (el) {
function appendToStack(el) {
// Don't call .appendChild if #mocha-report was already .shift()'ed off the stack.

@@ -220,5 +247,5 @@ if (stack[0]) {

function updateStats () {
function updateStats() {
// TODO: add to stats
var percent = stats.tests / runner.total * 100 | 0;
var percent = (stats.tests / runner.total * 100) | 0;
if (progress) {

@@ -242,3 +269,3 @@ progress.update(percent).draw(ctx);

*/
function makeUrl (s) {
function makeUrl(s) {
var search = window.location.search;

@@ -251,3 +278,8 @@

return window.location.pathname + (search ? search + '&' : '?') + 'grep=' + encodeURIComponent(escapeRe(s));
return (
window.location.pathname +
(search ? search + '&' : '?') +
'grep=' +
encodeURIComponent(escapeRe(s))
);
}

@@ -260,3 +292,3 @@

*/
HTML.prototype.suiteURL = function (suite) {
HTML.prototype.suiteURL = function(suite) {
return makeUrl(suite.fullTitle());

@@ -270,3 +302,3 @@ };

*/
HTML.prototype.testURL = function (test) {
HTML.prototype.testURL = function(test) {
return makeUrl(test.fullTitle());

@@ -281,6 +313,6 @@ };

*/
HTML.prototype.addCodeToggle = function (el, contents) {
HTML.prototype.addCodeToggle = function(el, contents) {
var h2 = el.getElementsByTagName('h2')[0];
on(h2, 'click', function () {
on(h2, 'click', function() {
pre.style.display = pre.style.display === 'none' ? 'block' : 'none';

@@ -299,3 +331,3 @@ });

*/
function error (msg) {
function error(msg) {
document.body.appendChild(fragment('<div id="mocha-error">%s</div>', msg));

@@ -309,3 +341,3 @@ }

*/
function fragment (html) {
function fragment(html) {
var args = arguments;

@@ -315,6 +347,8 @@ var div = document.createElement('div');

div.innerHTML = html.replace(/%([se])/g, function (_, type) {
div.innerHTML = html.replace(/%([se])/g, function(_, type) {
switch (type) {
case 's': return String(args[i++]);
case 'e': return escape(args[i++]);
case 's':
return String(args[i++]);
case 'e':
return escape(args[i++]);
// no default

@@ -333,3 +367,3 @@ }

*/
function hideSuitesWithout (classname) {
function hideSuitesWithout(classname) {
var suites = document.getElementsByClassName('suite');

@@ -347,3 +381,3 @@ for (var i = 0; i < suites.length; i++) {

*/
function unhide () {
function unhide() {
var els = document.getElementsByClassName('suite hidden');

@@ -361,3 +395,3 @@ for (var i = 0; i < els.length; ++i) {

*/
function text (el, contents) {
function text(el, contents) {
if (el.textContent) {

@@ -373,3 +407,3 @@ el.textContent = contents;

*/
function on (el, event, fn) {
function on(el, event, fn) {
if (el.addEventListener) {

@@ -376,0 +410,0 @@ el.addEventListener(event, fn, false);

@@ -28,3 +28,3 @@ 'use strict';

*/
function List (runner) {
function List(runner) {
Base.call(this, runner);

@@ -35,11 +35,11 @@

runner.on('start', function () {
console.log(JSON.stringify(['start', { total: total }]));
runner.on('start', function() {
console.log(JSON.stringify(['start', {total: total}]));
});
runner.on('pass', function (test) {
runner.on('pass', function(test) {
console.log(JSON.stringify(['pass', clean(test)]));
});
runner.on('fail', function (test, err) {
runner.on('fail', function(test, err) {
test = clean(test);

@@ -51,3 +51,3 @@ test.err = err.message;

runner.once('end', function () {
runner.once('end', function() {
process.stdout.write(JSON.stringify(['end', self.stats]));

@@ -65,3 +65,3 @@ });

*/
function clean (test) {
function clean(test) {
return {

@@ -68,0 +68,0 @@ title: test.title,

@@ -27,3 +27,3 @@ 'use strict';

*/
function JSONReporter (runner) {
function JSONReporter(runner) {
Base.call(this, runner);

@@ -37,19 +37,19 @@

runner.on('test end', function (test) {
runner.on('test end', function(test) {
tests.push(test);
});
runner.on('pass', function (test) {
runner.on('pass', function(test) {
passes.push(test);
});
runner.on('fail', function (test) {
runner.on('fail', function(test) {
failures.push(test);
});
runner.on('pending', function (test) {
runner.on('pending', function(test) {
pending.push(test);
});
runner.once('end', function () {
runner.once('end', function() {
var obj = {

@@ -77,3 +77,3 @@ stats: self.stats,

*/
function clean (test) {
function clean(test) {
var err = test.err || {};

@@ -100,15 +100,17 @@ if (err instanceof Error) {

*/
function cleanCycles (obj) {
function cleanCycles(obj) {
var cache = [];
return JSON.parse(JSON.stringify(obj, function (key, value) {
if (typeof value === 'object' && value !== null) {
if (cache.indexOf(value) !== -1) {
// Instead of going in a circle, we'll print [object Object]
return '' + value;
return JSON.parse(
JSON.stringify(obj, function(key, value) {
if (typeof value === 'object' && value !== null) {
if (cache.indexOf(value) !== -1) {
// Instead of going in a circle, we'll print [object Object]
return '' + value;
}
cache.push(value);
}
cache.push(value);
}
return value;
}));
return value;
})
);
}

@@ -123,5 +125,5 @@

*/
function errorJSON (err) {
function errorJSON(err) {
var res = {};
Object.getOwnPropertyNames(err).forEach(function (key) {
Object.getOwnPropertyNames(err).forEach(function(key) {
res[key] = err[key];

@@ -128,0 +130,0 @@ }, err);

@@ -48,7 +48,7 @@ 'use strict';

*/
function Landing (runner) {
function Landing(runner) {
Base.call(this, runner);
var self = this;
var width = Base.window.width * 0.75 | 0;
var width = (Base.window.width * 0.75) | 0;
var total = runner.total;

@@ -60,3 +60,3 @@ var stream = process.stdout;

function runway () {
function runway() {
var buf = Array(width).join('-');

@@ -66,3 +66,3 @@ return ' ' + color('runway', buf);

runner.on('start', function () {
runner.on('start', function() {
stream.write('\n\n\n ');

@@ -72,5 +72,5 @@ cursor.hide();

runner.on('test end', function (test) {
runner.on('test end', function(test) {
// check if the plane crashed
var col = crashed === -1 ? width * ++n / total | 0 : crashed;
var col = crashed === -1 ? (width * ++n / total) | 0 : crashed;

@@ -94,3 +94,3 @@ // show the crash

runner.once('end', function () {
runner.once('end', function() {
cursor.show();

@@ -97,0 +97,0 @@ console.log();

@@ -30,3 +30,3 @@ 'use strict';

*/
function List (runner) {
function List(runner) {
Base.call(this, runner);

@@ -37,18 +37,18 @@

runner.on('start', function () {
runner.on('start', function() {
console.log();
});
runner.on('test', function (test) {
runner.on('test', function(test) {
process.stdout.write(color('pass', ' ' + test.fullTitle() + ': '));
});
runner.on('pending', function (test) {
var fmt = color('checkmark', ' -') +
color('pending', ' %s');
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', ' ' + Base.symbols.ok) +
runner.on('pass', function(test) {
var fmt =
color('checkmark', ' ' + Base.symbols.ok) +
color('pass', ' %s: ') +

@@ -60,3 +60,3 @@ color(test.speed, '%dms');

runner.on('fail', function (test) {
runner.on('fail', function(test) {
cursor.CR();

@@ -63,0 +63,0 @@ console.log(color('fail', ' %d) %s'), ++n, test.fullTitle());

@@ -34,3 +34,3 @@ 'use strict';

*/
function Markdown (runner) {
function Markdown(runner) {
Base.call(this, runner);

@@ -41,12 +41,12 @@

function title (str) {
function title(str) {
return Array(level).join('#') + ' ' + str;
}
function mapTOC (suite, obj) {
function mapTOC(suite, obj) {
var ret = obj;
var key = SUITE_PREFIX + suite.title;
obj = obj[key] = obj[key] || { suite: suite };
suite.suites.forEach(function (suite) {
obj = obj[key] = obj[key] || {suite: suite};
suite.suites.forEach(function(suite) {
mapTOC(suite, obj);

@@ -58,3 +58,3 @@ });

function stringifyTOC (obj, level) {
function stringifyTOC(obj, level) {
++level;

@@ -77,3 +77,3 @@ var buf = '';

function generateTOC (suite) {
function generateTOC(suite) {
var obj = mapTOC(suite, {});

@@ -85,3 +85,3 @@ return stringifyTOC(obj, 0);

runner.on('suite', function (suite) {
runner.on('suite', function(suite) {
++level;

@@ -93,7 +93,7 @@ var slug = utils.slug(suite.fullTitle());

runner.on('suite end', function () {
runner.on('suite end', function() {
--level;
});
runner.on('pass', function (test) {
runner.on('pass', function(test) {
var code = utils.clean(test.body);

@@ -106,3 +106,3 @@ buf += test.title + '.\n';

runner.once('end', function () {
runner.once('end', function() {
process.stdout.write('# TOC\n');

@@ -109,0 +109,0 @@ process.stdout.write(generateTOC(runner.suite));

@@ -28,6 +28,6 @@ 'use strict';

*/
function Min (runner) {
function Min(runner) {
Base.call(this, runner);
runner.on('start', function () {
runner.on('start', function() {
// clear screen

@@ -34,0 +34,0 @@ process.stdout.write('\u001b[2J');

@@ -29,8 +29,8 @@ 'use strict';

function NyanCat (runner) {
function NyanCat(runner) {
Base.call(this, runner);
var self = this;
var width = Base.window.width * 0.75 | 0;
var nyanCatWidth = this.nyanCatWidth = 11;
var width = (Base.window.width * 0.75) | 0;
var nyanCatWidth = (this.nyanCatWidth = 11);

@@ -43,5 +43,5 @@ this.colorIndex = 0;

this.trajectories = [[], [], [], []];
this.trajectoryWidthMax = (width - nyanCatWidth);
this.trajectoryWidthMax = width - nyanCatWidth;
runner.on('start', function () {
runner.on('start', function() {
Base.cursor.hide();

@@ -51,15 +51,15 @@ self.draw();

runner.on('pending', function () {
runner.on('pending', function() {
self.draw();
});
runner.on('pass', function () {
runner.on('pass', function() {
self.draw();
});
runner.on('fail', function () {
runner.on('fail', function() {
self.draw();
});
runner.once('end', function () {
runner.once('end', function() {
Base.cursor.show();

@@ -84,3 +84,3 @@ for (var i = 0; i < self.numberOfLines; i++) {

NyanCat.prototype.draw = function () {
NyanCat.prototype.draw = function() {
this.appendRainbow();

@@ -100,6 +100,6 @@ this.drawScoreboard();

NyanCat.prototype.drawScoreboard = function () {
NyanCat.prototype.drawScoreboard = function() {
var stats = this.stats;
function draw (type, n) {
function draw(type, n) {
write(' ');

@@ -124,3 +124,3 @@ write(Base.color(type, n));

NyanCat.prototype.appendRainbow = function () {
NyanCat.prototype.appendRainbow = function() {
var segment = this.tick ? '_' : '-';

@@ -144,6 +144,6 @@ var rainbowified = this.rainbowify(segment);

NyanCat.prototype.drawRainbow = function () {
NyanCat.prototype.drawRainbow = function() {
var self = this;
this.trajectories.forEach(function (line) {
this.trajectories.forEach(function(line) {
write('\u001b[' + self.scoreboardWidth + 'C');

@@ -162,3 +162,3 @@ write(line.join(''));

*/
NyanCat.prototype.drawNyanCat = function () {
NyanCat.prototype.drawNyanCat = function() {
var self = this;

@@ -199,3 +199,3 @@ var startWidth = this.scoreboardWidth + this.trajectories[0].length;

NyanCat.prototype.face = function () {
NyanCat.prototype.face = function() {
var stats = this.stats;

@@ -219,3 +219,3 @@ if (stats.failures) {

NyanCat.prototype.cursorUp = function (n) {
NyanCat.prototype.cursorUp = function(n) {
write('\u001b[' + n + 'A');

@@ -231,3 +231,3 @@ };

NyanCat.prototype.cursorDown = function (n) {
NyanCat.prototype.cursorDown = function(n) {
write('\u001b[' + n + 'B');

@@ -242,8 +242,8 @@ };

*/
NyanCat.prototype.generateColors = function () {
NyanCat.prototype.generateColors = function() {
var colors = [];
for (var i = 0; i < (6 * 7); i++) {
for (var i = 0; i < 6 * 7; i++) {
var pi3 = Math.floor(Math.PI / 3);
var n = (i * (1.0 / 6));
var n = i * (1.0 / 6);
var r = Math.floor(3 * Math.sin(n) + 3);

@@ -265,3 +265,3 @@ var g = Math.floor(3 * Math.sin(n + 2 * pi3) + 3);

*/
NyanCat.prototype.rainbowify = function (str) {
NyanCat.prototype.rainbowify = function(str) {
if (!Base.useColors) {

@@ -280,4 +280,4 @@ return str;

*/
function write (string) {
function write(string) {
process.stdout.write(string);
}

@@ -37,7 +37,7 @@ 'use strict';

*/
function Progress (runner, options) {
function Progress(runner, options) {
Base.call(this, runner);
var self = this;
var width = Base.window.width * 0.50 | 0;
var width = (Base.window.width * 0.5) | 0;
var total = runner.total;

@@ -58,3 +58,3 @@ var complete = 0;

// tests started
runner.on('start', function () {
runner.on('start', function() {
console.log();

@@ -65,7 +65,7 @@ cursor.hide();

// tests complete
runner.on('test end', function () {
runner.on('test end', function() {
complete++;
var percent = complete / total;
var n = width * percent | 0;
var n = (width * percent) | 0;
var i = width - n;

@@ -92,3 +92,3 @@

// and the failures if any
runner.once('end', function () {
runner.once('end', function() {
cursor.show();

@@ -95,0 +95,0 @@ console.log();

@@ -29,3 +29,3 @@ 'use strict';

*/
function Spec (runner) {
function Spec(runner) {
Base.call(this, runner);

@@ -37,11 +37,11 @@

function indent () {
function indent() {
return Array(indents).join(' ');
}
runner.on('start', function () {
runner.on('start', function() {
console.log();
});
runner.on('suite', function (suite) {
runner.on('suite', function(suite) {
++indents;

@@ -51,3 +51,3 @@ console.log(color('suite', '%s%s'), indent(), suite.title);

runner.on('suite end', function () {
runner.on('suite end', function() {
--indents;

@@ -59,3 +59,3 @@ if (indents === 1) {

runner.on('pending', function (test) {
runner.on('pending', function(test) {
var fmt = indent() + color('pending', ' - %s');

@@ -65,6 +65,7 @@ console.log(fmt, test.title);

runner.on('pass', function (test) {
runner.on('pass', function(test) {
var fmt;
if (test.speed === 'fast') {
fmt = indent() +
fmt =
indent() +
color('checkmark', ' ' + Base.symbols.ok) +

@@ -74,3 +75,4 @@ color('pass', ' %s');

} else {
fmt = indent() +
fmt =
indent() +
color('checkmark', ' ' + Base.symbols.ok) +

@@ -83,3 +85,3 @@ color('pass', ' %s') +

runner.on('fail', function (test) {
runner.on('fail', function(test) {
console.log(indent() + color('fail', ' %d) %s'), ++n, test.title);

@@ -86,0 +88,0 @@ });

@@ -27,3 +27,3 @@ 'use strict';

*/
function TAP (runner) {
function TAP(runner) {
Base.call(this, runner);

@@ -35,3 +35,3 @@

runner.on('start', function () {
runner.on('start', function() {
var total = runner.grepTotal(runner.suite);

@@ -41,11 +41,11 @@ console.log('%d..%d', 1, total);

runner.on('test end', function () {
runner.on('test end', function() {
++n;
});
runner.on('pending', function (test) {
runner.on('pending', function(test) {
console.log('ok %d %s # SKIP -', n, title(test));
});
runner.on('pass', function (test) {
runner.on('pass', function(test) {
passes++;

@@ -55,3 +55,3 @@ console.log('ok %d %s', n, title(test));

runner.on('fail', function (test, err) {
runner.on('fail', function(test, err) {
failures++;

@@ -64,3 +64,3 @@ console.log('not ok %d %s', n, title(test));

runner.once('end', function () {
runner.once('end', function() {
console.log('# tests ' + (passes + failures));

@@ -79,4 +79,4 @@ console.log('# pass ' + passes);

*/
function title (test) {
function title(test) {
return test.fullTitle().replace(/#/g, '');
}

@@ -45,3 +45,3 @@ 'use strict';

*/
function XUnit (runner, options) {
function XUnit(runner, options) {
Base.call(this, runner);

@@ -76,26 +76,32 @@

runner.on('pending', function (test) {
runner.on('pending', function(test) {
tests.push(test);
});
runner.on('pass', function (test) {
runner.on('pass', function(test) {
tests.push(test);
});
runner.on('fail', function (test) {
runner.on('fail', function(test) {
tests.push(test);
});
runner.once('end', function () {
self.write(tag('testsuite', {
name: suiteName,
tests: stats.tests,
failures: stats.failures,
errors: stats.failures,
skipped: stats.tests - stats.failures - stats.passes,
timestamp: (new Date()).toUTCString(),
time: (stats.duration / 1000) || 0
}, false));
runner.once('end', function() {
self.write(
tag(
'testsuite',
{
name: suiteName,
tests: stats.tests,
failures: stats.failures,
errors: stats.failures,
skipped: stats.tests - stats.failures - stats.passes,
timestamp: new Date().toUTCString(),
time: stats.duration / 1000 || 0
},
false
)
);
tests.forEach(function (t) {
tests.forEach(function(t) {
self.test(t);

@@ -119,5 +125,5 @@ });

*/
XUnit.prototype.done = function (failures, fn) {
XUnit.prototype.done = function(failures, fn) {
if (this.fileStream) {
this.fileStream.end(function () {
this.fileStream.end(function() {
fn(failures);

@@ -135,3 +141,3 @@ });

*/
XUnit.prototype.write = function (line) {
XUnit.prototype.write = function(line) {
if (this.fileStream) {

@@ -151,7 +157,7 @@ this.fileStream.write(line + '\n');

*/
XUnit.prototype.test = function (test) {
XUnit.prototype.test = function(test) {
var attrs = {
classname: test.parent.fullTitle(),
name: test.title,
time: (test.duration / 1000) || 0
time: test.duration / 1000 || 0
};

@@ -161,3 +167,15 @@

var err = test.err;
this.write(tag('testcase', attrs, false, tag('failure', {}, false, escape(err.message) + '\n' + escape(err.stack))));
this.write(
tag(
'testcase',
attrs,
false,
tag(
'failure',
{},
false,
escape(err.message) + '\n' + escape(err.stack)
)
)
);
} else if (test.isPending()) {

@@ -179,3 +197,3 @@ this.write(tag('testcase', attrs, false, tag('skipped', {}, true)));

*/
function tag (name, attrs, close, content) {
function tag(name, attrs, close, content) {
var end = close ? '/>' : '>';

@@ -182,0 +200,0 @@ var pairs = [];

'use strict';
/**
* @module Runnable
*/
/**
* Module dependencies.
*/
var EventEmitter = require('events').EventEmitter;

@@ -26,12 +20,4 @@ var Pending = require('./pending');

/**
* Object#toString().
*/
var toString = Object.prototype.toString;
/**
* Expose `Runnable`.
*/
module.exports = Runnable;

@@ -42,9 +28,8 @@

*
* @memberof Mocha
* @public
* @class
* @extends EventEmitter
* @param {String} title
* @param {Function} fn
*/
function Runnable (title, fn) {
function Runnable(title, fn) {
this.title = title;

@@ -76,3 +61,3 @@ this.fn = fn;

*/
Runnable.prototype.timeout = function (ms) {
Runnable.prototype.timeout = function(ms) {
if (!arguments.length) {

@@ -103,3 +88,3 @@ return this._timeout;

*/
Runnable.prototype.slow = function (ms) {
Runnable.prototype.slow = function(ms) {
if (!arguments.length || typeof ms === 'undefined') {

@@ -123,3 +108,3 @@ return this._slow;

*/
Runnable.prototype.enableTimeouts = function (enabled) {
Runnable.prototype.enableTimeouts = function(enabled) {
if (!arguments.length) {

@@ -140,3 +125,3 @@ return this._enableTimeouts;

*/
Runnable.prototype.skip = function () {
Runnable.prototype.skip = function() {
throw new Pending('sync skip');

@@ -150,3 +135,3 @@ };

*/
Runnable.prototype.isPending = function () {
Runnable.prototype.isPending = function() {
return this.pending || (this.parent && this.parent.isPending());

@@ -160,3 +145,3 @@ };

*/
Runnable.prototype.isFailed = function () {
Runnable.prototype.isFailed = function() {
return !this.isPending() && this.state === 'failed';

@@ -170,3 +155,3 @@ };

*/
Runnable.prototype.isPassed = function () {
Runnable.prototype.isPassed = function() {
return !this.isPending() && this.state === 'passed';

@@ -180,3 +165,3 @@ };

*/
Runnable.prototype.retries = function (n) {
Runnable.prototype.retries = function(n) {
if (!arguments.length) {

@@ -193,3 +178,3 @@ return this._retries;

*/
Runnable.prototype.currentRetry = function (n) {
Runnable.prototype.currentRetry = function(n) {
if (!arguments.length) {

@@ -210,3 +195,3 @@ return this._currentRetry;

*/
Runnable.prototype.fullTitle = function () {
Runnable.prototype.fullTitle = function() {
return this.titlePath().join(' ');

@@ -223,3 +208,3 @@ };

*/
Runnable.prototype.titlePath = function () {
Runnable.prototype.titlePath = function() {
return this.parent.titlePath().concat([this.title]);

@@ -233,3 +218,3 @@ };

*/
Runnable.prototype.clearTimeout = function () {
Runnable.prototype.clearTimeout = function() {
clearTimeout(this.timer);

@@ -244,15 +229,19 @@ };

*/
Runnable.prototype.inspect = function () {
return JSON.stringify(this, function (key, val) {
if (key[0] === '_') {
return;
}
if (key === 'parent') {
return '#<Suite>';
}
if (key === 'ctx') {
return '#<Context>';
}
return val;
}, 2);
Runnable.prototype.inspect = function() {
return JSON.stringify(
this,
function(key, val) {
if (key[0] === '_') {
return;
}
if (key === 'parent') {
return '#<Suite>';
}
if (key === 'ctx') {
return '#<Context>';
}
return val;
},
2
);
};

@@ -265,3 +254,3 @@

*/
Runnable.prototype.resetTimeout = function () {
Runnable.prototype.resetTimeout = function() {
var self = this;

@@ -274,3 +263,3 @@ var ms = this.timeout() || 1e9;

this.clearTimeout();
this.timer = setTimeout(function () {
this.timer = setTimeout(function() {
if (!self._enableTimeouts) {

@@ -290,3 +279,3 @@ return;

*/
Runnable.prototype.globals = function (globals) {
Runnable.prototype.globals = function(globals) {
if (!arguments.length) {

@@ -304,3 +293,3 @@ return this._allowedGlobals;

*/
Runnable.prototype.run = function (fn) {
Runnable.prototype.run = function(fn) {
var self = this;

@@ -318,3 +307,3 @@ var start = new Date();

// called multiple times
function multiple (err) {
function multiple(err) {
if (emitted) {

@@ -334,3 +323,3 @@ return;

// finished
function done (err) {
function done(err) {
var ms = self.timeout();

@@ -362,3 +351,3 @@ if (self.timedOut) {

// allows skip() to be used in an explicit async context
this.skip = function asyncSkip () {
this.skip = function asyncSkip() {
done(new Pending('async skip call'));

@@ -404,8 +393,8 @@ // halt execution. the Runnable will be marked pending

function callFn (fn) {
function callFn(fn) {
var result = fn.call(ctx);
if (result && typeof result.then === 'function') {
self.resetTimeout();
result
.then(function () {
result.then(
function() {
done();

@@ -416,8 +405,13 @@ // Return null so libraries like bluebird do not warn about

},
function (reason) {
function(reason) {
done(reason || new Error('Promise rejected with no or falsy reason'));
});
}
);
} else {
if (self.asyncOnly) {
return done(new Error('--async-only option in use without declaring `done()` or returning a promise'));
return done(
new Error(
'--async-only option in use without declaring `done()` or returning a promise'
)
);
}

@@ -429,4 +423,4 @@

function callFnAsync (fn) {
var result = fn.call(ctx, function (err) {
function callFnAsync(fn) {
var result = fn.call(ctx, function(err) {
if (err instanceof Error || toString.call(err) === '[object Error]') {

@@ -437,4 +431,5 @@ return done(err);

if (Object.prototype.toString.call(err) === '[object Object]') {
return done(new Error('done() invoked with non-Error: ' +
JSON.stringify(err)));
return done(
new Error('done() invoked with non-Error: ' + JSON.stringify(err))
);
}

@@ -444,3 +439,7 @@ return done(new Error('done() invoked with non-Error: ' + err));

if (result && utils.isPromise(result)) {
return done(new Error('Resolution method is overspecified. Specify a callback *or* return a Promise; not both.'));
return done(
new Error(
'Resolution method is overspecified. Specify a callback *or* return a Promise; not both.'
)
);
}

@@ -460,4 +459,7 @@

*/
Runnable.prototype._timeoutError = function (ms) {
var msg = 'Timeout of ' + ms + 'ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves.';
Runnable.prototype._timeoutError = function(ms) {
var msg =
'Timeout of ' +
ms +
'ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves.';
if (this.file) {

@@ -464,0 +466,0 @@ msg += ' (' + this.file + ')';

@@ -66,3 +66,3 @@ 'use strict';

*/
function Runner (suite, delay) {
function Runner(suite, delay) {
var self = this;

@@ -76,6 +76,6 @@ this._globals = [];

this.failures = 0;
this.on('test end', function (test) {
this.on('test end', function(test) {
self.checkGlobals(test);
});
this.on('hook end', function (hook) {
this.on('hook end', function(hook) {
self.checkGlobals(hook);

@@ -112,3 +112,3 @@ });

*/
Runner.prototype.grep = function (re, invert) {
Runner.prototype.grep = function(re, invert) {
debug('grep %s', re);

@@ -131,7 +131,7 @@ this._grep = re;

*/
Runner.prototype.grepTotal = function (suite) {
Runner.prototype.grepTotal = function(suite) {
var self = this;
var total = 0;
suite.eachTest(function (test) {
suite.eachTest(function(test) {
var match = self._grep.test(test.fullTitle());

@@ -155,3 +155,3 @@ if (self._invert) {

*/
Runner.prototype.globalProps = function () {
Runner.prototype.globalProps = function() {
var props = Object.keys(global);

@@ -179,3 +179,3 @@

*/
Runner.prototype.globals = function (arr) {
Runner.prototype.globals = function(arr) {
if (!arguments.length) {

@@ -194,3 +194,3 @@ return this._globals;

*/
Runner.prototype.checkGlobals = function (test) {
Runner.prototype.checkGlobals = function(test) {
if (this.ignoreLeaks) {

@@ -217,3 +217,6 @@ return;

if (leaks.length > 1) {
this.fail(test, new Error('global leaks detected: ' + leaks.join(', ') + ''));
this.fail(
test,
new Error('global leaks detected: ' + leaks.join(', ') + '')
);
} else if (leaks.length) {

@@ -231,3 +234,3 @@ this.fail(test, new Error('global leak detected: ' + leaks[0]));

*/
Runner.prototype.fail = function (test, err) {
Runner.prototype.fail = function(test, err) {
if (test.isPending()) {

@@ -241,10 +244,15 @@ return;

if (!(err instanceof Error || (err && typeof err.message === 'string'))) {
err = new Error('the ' + type(err) + ' ' + stringify(err) + ' was thrown, throw an Error :)');
err = new Error(
'the ' +
type(err) +
' ' +
stringify(err) +
' was thrown, throw an Error :)'
);
}
try {
err.stack = (this.fullStackTrace || !err.stack)
? err.stack
: stackFilter(err.stack);
} catch (ignored) {
err.stack =
this.fullStackTrace || !err.stack ? err.stack : stackFilter(err.stack);
} catch (ignore) {
// some environments do not take kindly to monkeying with the stack

@@ -254,2 +262,5 @@ }

this.emit('fail', test, err);
if (this.suite.bail()) {
this.emit('end');
}
};

@@ -277,11 +288,9 @@

*/
Runner.prototype.failHook = function (hook, err) {
Runner.prototype.failHook = function(hook, err) {
if (hook.ctx && hook.ctx.currentTest) {
hook.originalTitle = hook.originalTitle || hook.title;
hook.title = hook.originalTitle + ' for "' + hook.ctx.currentTest.title + '"';
hook.title =
hook.originalTitle + ' for "' + hook.ctx.currentTest.title + '"';
}
if (this.suite.bail()) {
this.emit('end');
}
this.fail(hook, err);

@@ -298,3 +307,3 @@ };

Runner.prototype.hook = function (name, fn) {
Runner.prototype.hook = function(name, fn) {
var suite = this.suite;

@@ -304,3 +313,3 @@ var hooks = suite['_' + name];

function next (i) {
function next(i) {
var hook = hooks[i];

@@ -317,3 +326,3 @@ if (!hook) {

if (!hook.listeners('error').length) {
hook.on('error', function (err) {
hook.on('error', function(err) {
self.failHook(hook, err);

@@ -323,3 +332,3 @@ });

hook.run(function (err) {
hook.run(function(err) {
var testError = hook.error();

@@ -334,3 +343,3 @@ if (testError) {

} else {
suite.tests.forEach(function (test) {
suite.tests.forEach(function(test) {
test.pending = true;

@@ -354,3 +363,3 @@ });

Runner.immediately(function () {
Runner.immediately(function() {
next(0);

@@ -369,7 +378,7 @@ });

*/
Runner.prototype.hooks = function (name, suites, fn) {
Runner.prototype.hooks = function(name, suites, fn) {
var self = this;
var orig = this.suite;
function next (suite) {
function next(suite) {
self.suite = suite;

@@ -382,3 +391,3 @@

self.hook(name, function (err) {
self.hook(name, function(err) {
if (err) {

@@ -404,3 +413,3 @@ var errSuite = self.suite;

*/
Runner.prototype.hookUp = function (name, fn) {
Runner.prototype.hookUp = function(name, fn) {
var suites = [this.suite].concat(this.parents()).reverse();

@@ -417,3 +426,3 @@ this.hooks(name, suites, fn);

*/
Runner.prototype.hookDown = function (name, fn) {
Runner.prototype.hookDown = function(name, fn) {
var suites = [this.suite].concat(this.parents());

@@ -430,3 +439,3 @@ this.hooks(name, suites, fn);

*/
Runner.prototype.parents = function () {
Runner.prototype.parents = function() {
var suite = this.suite;

@@ -447,3 +456,3 @@ var suites = [];

*/
Runner.prototype.runTest = function (fn) {
Runner.prototype.runTest = function(fn) {
var self = this;

@@ -462,3 +471,3 @@ var test = this.test;

}
test.on('error', function (err) {
test.on('error', function(err) {
self.fail(test, err);

@@ -484,3 +493,3 @@ });

*/
Runner.prototype.runTests = function (suite, fn) {
Runner.prototype.runTests = function(suite, fn) {
var self = this;

@@ -490,3 +499,3 @@ var tests = suite.tests.slice();

function hookErr (_, errSuite, after) {
function hookErr(_, errSuite, after) {
// before/after Each hook for errSuite failed:

@@ -501,3 +510,3 @@ var orig = self.suite;

// call hookUp afterEach
self.hookUp('afterEach', function (err2, errSuite2) {
self.hookUp('afterEach', function(err2, errSuite2) {
self.suite = orig;

@@ -518,3 +527,3 @@ // some hooks may fail even now

function next (err, errSuite) {
function next(err, errSuite) {
// if we bail after first err

@@ -576,4 +585,4 @@ if (self.failures && suite._bail) {

// execute test and hook(s)
self.emit('test', self.test = test);
self.hookDown('beforeEach', function (err, errSuite) {
self.emit('test', (self.test = test));
self.hookDown('beforeEach', function(err, errSuite) {
if (test.isPending()) {

@@ -594,3 +603,3 @@ if (self.forbidPending) {

self.currentRunnable = self.test;
self.runTest(function (err) {
self.runTest(function(err) {
test = self.test;

@@ -637,3 +646,3 @@ if (err) {

function alwaysFalse () {
function alwaysFalse() {
return false;

@@ -649,3 +658,3 @@ }

*/
Runner.prototype.runSuite = function (suite, fn) {
Runner.prototype.runSuite = function(suite, fn) {
var i = 0;

@@ -662,5 +671,5 @@ var self = this;

this.emit('suite', this.suite = suite);
this.emit('suite', (this.suite = suite));
function next (errSuite) {
function next(errSuite) {
if (errSuite) {

@@ -691,3 +700,3 @@ // current suite failed on a hook from errSuite

if (self._grep !== self._defaultGrep) {
Runner.immediately(function () {
Runner.immediately(function() {
self.runSuite(curr, next);

@@ -700,3 +709,3 @@ });

function done (errSuite) {
function done(errSuite) {
self.suite = suite;

@@ -715,3 +724,3 @@ self.nextSuite = next;

self.hook('afterAll', function () {
self.hook('afterAll', function() {
self.emit('suite end', suite);

@@ -725,3 +734,3 @@ fn(errSuite);

this.hook('beforeAll', function (err) {
this.hook('beforeAll', function(err) {
if (err) {

@@ -740,7 +749,13 @@ return done();

*/
Runner.prototype.uncaught = function (err) {
Runner.prototype.uncaught = function(err) {
if (err) {
debug('uncaught exception %s', err === (function () {
return this;
}.call(err)) ? (err.message || err) : err);
debug(
'uncaught exception %s',
err ===
function() {
return this;
}.call(err)
? err.message || err
: err
);
} else {

@@ -818,4 +833,4 @@ debug('uncaught undefined exception');

*/
function cleanSuiteReferences (suite) {
function cleanArrReferences (arr) {
function cleanSuiteReferences(suite) {
function cleanArrReferences(arr) {
for (var i = 0; i < arr.length; i++) {

@@ -857,13 +872,13 @@ delete arr[i].fn;

*/
Runner.prototype.run = function (fn) {
Runner.prototype.run = function(fn) {
var self = this;
var rootSuite = this.suite;
fn = fn || function () {};
fn = fn || function() {};
function uncaught (err) {
function uncaught(err) {
self.uncaught(err);
}
function start () {
function start() {
// If there is an `only` filter

@@ -875,3 +890,3 @@ if (hasOnly(rootSuite)) {

self.emit('start');
self.runSuite(rootSuite, function () {
self.runSuite(rootSuite, function() {
debug('finished running');

@@ -888,3 +903,3 @@ self.emit('end');

// callback
this.on('end', function () {
this.on('end', function() {
debug('end');

@@ -918,3 +933,3 @@ process.removeListener('uncaughtException', uncaught);

*/
Runner.prototype.abort = function () {
Runner.prototype.abort = function() {
debug('aborting');

@@ -933,3 +948,3 @@ this._abort = true;

*/
function filterOnly (suite) {
function filterOnly(suite) {
if (suite._onlyTests.length) {

@@ -942,3 +957,3 @@ // If the suite contains `only` tests, run those and ignore any nested suites.

suite.tests = [];
suite._onlySuites.forEach(function (onlySuite) {
suite._onlySuites.forEach(function(onlySuite) {
// If there are other `only` tests/suites nested in the current `only` suite, then filter that `only` suite.

@@ -951,4 +966,6 @@ // Otherwise, all of the tests on this `only` suite should be run, so don't filter it.

// Run the `only` suites, as well as any other suites that have `only` tests/suites as descendants.
suite.suites = suite.suites.filter(function (childSuite) {
return suite._onlySuites.indexOf(childSuite) !== -1 || filterOnly(childSuite);
suite.suites = suite.suites.filter(function(childSuite) {
return (
suite._onlySuites.indexOf(childSuite) !== -1 || filterOnly(childSuite)
);
});

@@ -967,4 +984,8 @@ }

*/
function hasOnly (suite) {
return suite._onlyTests.length || suite._onlySuites.length || suite.suites.some(hasOnly);
function hasOnly(suite) {
return (
suite._onlyTests.length ||
suite._onlySuites.length ||
suite.suites.some(hasOnly)
);
}

@@ -980,4 +1001,4 @@

*/
function filterLeaks (ok, globals) {
return globals.filter(function (key) {
function filterLeaks(ok, globals) {
return globals.filter(function(key) {
// Firefox and Chrome exposes iframes as index inside the window object

@@ -991,3 +1012,3 @@ if (/^\d+/.test(key)) {

// not init at first it is assigned in some seconds
if (global.navigator && (/^getInterface/).test(key)) {
if (global.navigator && /^getInterface/.test(key)) {
return false;

@@ -998,3 +1019,3 @@ }

// in ie6,7,8 and opera, iframeIndex is enumerable, this could cause leak
if (global.navigator && (/^\d+/).test(key)) {
if (global.navigator && /^\d+/.test(key)) {
return false;

@@ -1008,3 +1029,3 @@ }

var matched = ok.filter(function (ok) {
var matched = ok.filter(function(ok) {
if (~ok.indexOf('*')) {

@@ -1025,7 +1046,7 @@ return key.indexOf(ok.split('*')[0]) === 0;

*/
function extraGlobals () {
function extraGlobals() {
if (typeof process === 'object' && typeof process.version === 'string') {
var parts = process.version.split('.');
var nodeVersion = parts.reduce(function (a, v) {
return a << 8 | v;
var nodeVersion = parts.reduce(function(a, v) {
return (a << 8) | v;
});

@@ -1035,3 +1056,3 @@

if (nodeVersion < 0x00090B) {
if (nodeVersion < 0x00090b) {
return ['errno'];

@@ -1038,0 +1059,0 @@ }

@@ -34,3 +34,3 @@ 'use strict';

*/
exports.create = function (parent, title) {
exports.create = function(parent, title) {
var suite = new Suite(title, parent.ctx);

@@ -52,8 +52,12 @@ suite.parent = parent;

*/
function Suite (title, parentContext) {
function Suite(title, parentContext) {
if (!utils.isString(title)) {
throw new Error('Suite `title` should be a "string" but "' + typeof title + '" was given instead.');
throw new Error(
'Suite `title` should be a "string" but "' +
typeof title +
'" was given instead.'
);
}
this.title = title;
function Context () {}
function Context() {}
Context.prototype = parentContext;

@@ -90,3 +94,3 @@ this.ctx = new Context();

*/
Suite.prototype.clone = function () {
Suite.prototype.clone = function() {
var suite = new Suite(this.title);

@@ -110,3 +114,3 @@ debug('clone');

*/
Suite.prototype.timeout = function (ms) {
Suite.prototype.timeout = function(ms) {
if (!arguments.length) {

@@ -133,3 +137,3 @@ return this._timeout;

*/
Suite.prototype.retries = function (n) {
Suite.prototype.retries = function(n) {
if (!arguments.length) {

@@ -144,9 +148,9 @@ return this._retries;

/**
* Set or get timeout to `enabled`.
*
* @api private
* @param {boolean} enabled
* @return {Suite|boolean} self or enabled
*/
Suite.prototype.enableTimeouts = function (enabled) {
* Set or get timeout to `enabled`.
*
* @api private
* @param {boolean} enabled
* @return {Suite|boolean} self or enabled
*/
Suite.prototype.enableTimeouts = function(enabled) {
if (!arguments.length) {

@@ -167,3 +171,3 @@ return this._enableTimeouts;

*/
Suite.prototype.slow = function (ms) {
Suite.prototype.slow = function(ms) {
if (!arguments.length) {

@@ -187,3 +191,3 @@ return this._slow;

*/
Suite.prototype.bail = function (bail) {
Suite.prototype.bail = function(bail) {
if (!arguments.length) {

@@ -202,3 +206,3 @@ return this._bail;

*/
Suite.prototype.isPending = function () {
Suite.prototype.isPending = function() {
return this.pending || (this.parent && this.parent.isPending());

@@ -214,3 +218,3 @@ };

*/
Suite.prototype._createHook = function (title, fn) {
Suite.prototype._createHook = function(title, fn) {
var hook = new Hook(title, fn);

@@ -235,3 +239,3 @@ hook.parent = this;

*/
Suite.prototype.beforeAll = function (title, fn) {
Suite.prototype.beforeAll = function(title, fn) {
if (this.isPending()) {

@@ -260,3 +264,3 @@ return this;

*/
Suite.prototype.afterAll = function (title, fn) {
Suite.prototype.afterAll = function(title, fn) {
if (this.isPending()) {

@@ -285,3 +289,3 @@ return this;

*/
Suite.prototype.beforeEach = function (title, fn) {
Suite.prototype.beforeEach = function(title, fn) {
if (this.isPending()) {

@@ -310,3 +314,3 @@ return this;

*/
Suite.prototype.afterEach = function (title, fn) {
Suite.prototype.afterEach = function(title, fn) {
if (this.isPending()) {

@@ -334,3 +338,3 @@ return this;

*/
Suite.prototype.addSuite = function (suite) {
Suite.prototype.addSuite = function(suite) {
suite.parent = this;

@@ -354,3 +358,3 @@ suite.timeout(this.timeout());

*/
Suite.prototype.addTest = function (test) {
Suite.prototype.addTest = function(test) {
test.parent = this;

@@ -376,3 +380,3 @@ test.timeout(this.timeout());

*/
Suite.prototype.fullTitle = function () {
Suite.prototype.fullTitle = function() {
return this.titlePath().join(' ');

@@ -390,3 +394,3 @@ };

*/
Suite.prototype.titlePath = function () {
Suite.prototype.titlePath = function() {
var result = [];

@@ -410,6 +414,8 @@ if (this.parent) {

*/
Suite.prototype.total = function () {
return this.suites.reduce(function (sum, suite) {
return sum + suite.total();
}, 0) + this.tests.length;
Suite.prototype.total = function() {
return (
this.suites.reduce(function(sum, suite) {
return sum + suite.total();
}, 0) + this.tests.length
);
};

@@ -425,5 +431,5 @@

*/
Suite.prototype.eachTest = function (fn) {
Suite.prototype.eachTest = function(fn) {
this.tests.forEach(fn);
this.suites.forEach(function (suite) {
this.suites.forEach(function(suite) {
suite.eachTest(fn);

@@ -437,3 +443,3 @@ });

*/
Suite.prototype.run = function run () {
Suite.prototype.run = function run() {
if (this.root) {

@@ -440,0 +446,0 @@ this.emit('run');

'use strict';
/**
* Module dependencies.
*/
var Runnable = require('./runnable');

@@ -11,6 +6,2 @@ var utils = require('./utils');

/**
* Expose `Test`.
*/
module.exports = Test;

@@ -21,9 +12,14 @@

*
* @api private
* @class
* @extends Runnable
* @param {String} title
* @param {Function} fn
*/
function Test (title, fn) {
function Test(title, fn) {
if (!isString(title)) {
throw new Error('Test `title` should be a "string" but "' + typeof title + '" was given instead.');
throw new Error(
'Test `title` should be a "string" but "' +
typeof title +
'" was given instead.'
);
}

@@ -40,3 +36,3 @@ Runnable.call(this, title, fn);

Test.prototype.clone = function () {
Test.prototype.clone = function() {
var test = new Test(this.title, this.fn);

@@ -43,0 +39,0 @@ test.timeout(this.timeout());

@@ -33,4 +33,4 @@ 'use strict';

*/
exports.escape = function (html) {
return he.encode(String(html), { useNamedReferences: false });
exports.escape = function(html) {
return he.encode(String(html), {useNamedReferences: false});
};

@@ -45,3 +45,3 @@

*/
exports.isString = function (obj) {
exports.isString = function(obj) {
return typeof obj === 'string';

@@ -58,7 +58,7 @@ };

*/
exports.watch = function (files, fn) {
var options = { interval: 100 };
files.forEach(function (file) {
exports.watch = function(files, fn) {
var options = {interval: 100};
files.forEach(function(file) {
debug('file %s', file);
fs.watchFile(file, options, function (curr, prev) {
fs.watchFile(file, options, function(curr, prev) {
if (prev.mtime < curr.mtime) {

@@ -78,3 +78,3 @@ fn(file);

*/
function ignored (path) {
function ignored(path) {
return !~ignore.indexOf(path);

@@ -92,3 +92,3 @@ }

*/
exports.files = function (dir, ext, ret) {
exports.files = function(dir, ext, ret) {
ret = ret || [];

@@ -99,5 +99,6 @@ ext = ext || ['js'];

fs.readdirSync(dir)
fs
.readdirSync(dir)
.filter(ignored)
.forEach(function (path) {
.forEach(function(path) {
path = join(dir, path);

@@ -121,3 +122,3 @@ if (fs.lstatSync(path).isDirectory()) {

*/
exports.slug = function (str) {
exports.slug = function(str) {
return str

@@ -135,11 +136,18 @@ .toLowerCase()

*/
exports.clean = function (str) {
exports.clean = function(str) {
str = str
.replace(/\r\n?|[\n\u2028\u2029]/g, '\n').replace(/^\uFEFF/, '')
.replace(/\r\n?|[\n\u2028\u2029]/g, '\n')
.replace(/^\uFEFF/, '')
// (traditional)-> space/name parameters body (lambda)-> parameters body multi-statement/single keep body content
.replace(/^function(?:\s*|\s+[^(]*)\([^)]*\)\s*\{((?:.|\n)*?)\s*\}$|^\([^)]*\)\s*=>\s*(?:\{((?:.|\n)*?)\s*\}|((?:.|\n)*))$/, '$1$2$3');
.replace(
/^function(?:\s*|\s+[^(]*)\([^)]*\)\s*\{((?:.|\n)*?)\s*\}$|^\([^)]*\)\s*=>\s*(?:\{((?:.|\n)*?)\s*\}|((?:.|\n)*))$/,
'$1$2$3'
);
var spaces = str.match(/^\n?( *)/)[1].length;
var tabs = str.match(/^\n?(\t*)/)[1].length;
var re = new RegExp('^\n?' + (tabs ? '\t' : ' ') + '{' + (tabs || spaces) + '}', 'gm');
var re = new RegExp(
'^\n?' + (tabs ? '\t' : ' ') + '{' + (tabs || spaces) + '}',
'gm'
);

@@ -158,13 +166,16 @@ str = str.replace(re, '');

*/
exports.parseQuery = function (qs) {
return qs.replace('?', '').split('&').reduce(function (obj, pair) {
var i = pair.indexOf('=');
var key = pair.slice(0, i);
var val = pair.slice(++i);
exports.parseQuery = function(qs) {
return qs
.replace('?', '')
.split('&')
.reduce(function(obj, pair) {
var i = pair.indexOf('=');
var key = pair.slice(0, i);
var val = pair.slice(++i);
// Due to how the URLSearchParams API treats spaces
obj[key] = decodeURIComponent(val.replace(/\+/g, '%20'));
// Due to how the URLSearchParams API treats spaces
obj[key] = decodeURIComponent(val.replace(/\+/g, '%20'));
return obj;
}, {});
return obj;
}, {});
};

@@ -179,3 +190,3 @@

*/
function highlight (js) {
function highlight(js) {
return js

@@ -188,4 +199,10 @@ .replace(/</g, '&lt;')

.replace(/(\d+)/gm, '<span class="number">$1</span>')
.replace(/\bnew[ \t]+(\w+)/gm, '<span class="keyword">new</span> <span class="init">$1</span>')
.replace(/\b(function|new|throw|return|var|if|else)\b/gm, '<span class="keyword">$1</span>');
.replace(
/\bnew[ \t]+(\w+)/gm,
'<span class="keyword">new</span> <span class="init">$1</span>'
)
.replace(
/\b(function|new|throw|return|var|if|else)\b/gm,
'<span class="keyword">$1</span>'
);
}

@@ -199,3 +216,3 @@

*/
exports.highlightTags = function (name) {
exports.highlightTags = function(name) {
var code = document.getElementById('mocha').getElementsByTagName(name);

@@ -221,3 +238,3 @@ for (var i = 0, len = code.length; i < len; ++i) {

*/
function emptyRepresentation (value, typeHint) {
function emptyRepresentation(value, typeHint) {
switch (typeHint) {

@@ -256,3 +273,3 @@ case 'function':

*/
var type = exports.type = function type (value) {
var type = (exports.type = function type(value) {
if (value === undefined) {

@@ -265,6 +282,7 @@ return 'undefined';

}
return Object.prototype.toString.call(value)
return Object.prototype.toString
.call(value)
.replace(/^\[.+\s(.+?)]$/, '$1')
.toLowerCase();
};
});

@@ -286,3 +304,3 @@ /**

*/
exports.stringify = function (value) {
exports.stringify = function(value) {
var typeHint = type(value);

@@ -294,4 +312,6 @@

// Based on the toJSON result
return jsonStringify(json.data && json.type ? json.data : json, 2)
.replace(/,(\n|$)/g, '$1');
return jsonStringify(
json.data && json.type ? json.data : json,
2
).replace(/,(\n|$)/g, '$1');
}

@@ -302,3 +322,3 @@

if (typeHint === 'string' && typeof value === 'object') {
value = value.split('').reduce(function (acc, char, idx) {
value = value.split('').reduce(function(acc, char, idx) {
acc[idx] = char;

@@ -315,3 +335,6 @@ return acc;

if (Object.prototype.hasOwnProperty.call(value, prop)) {
return jsonStringify(exports.canonicalize(value, null, typeHint), 2).replace(/,(\n|$)/g, '$1');
return jsonStringify(
exports.canonicalize(value, null, typeHint),
2
).replace(/,(\n|$)/g, '$1');
}

@@ -332,3 +355,3 @@ }

*/
function jsonStringify (object, spaces, depth) {
function jsonStringify(object, spaces, depth) {
if (typeof spaces === 'undefined') {

@@ -343,9 +366,12 @@ // primitive types

var end = Array.isArray(object) ? ']' : '}';
var length = typeof object.length === 'number' ? object.length : Object.keys(object).length;
var length =
typeof object.length === 'number'
? object.length
: Object.keys(object).length;
// `.repeat()` polyfill
function repeat (s, n) {
function repeat(s, n) {
return new Array(n).join(s);
}
function _stringify (val) {
function _stringify(val) {
switch (type(val)) {

@@ -364,5 +390,6 @@ case 'null':

case 'number':
val = val === 0 && (1 / val) === -Infinity // `-0`
? '-0'
: val.toString();
val =
val === 0 && 1 / val === -Infinity // `-0`
? '-0'
: val.toString();
break;

@@ -380,5 +407,6 @@ case 'date':

default:
val = (val === '[Function]' || val === '[Circular]')
? val
: JSON.stringify(val); // string
val =
val === '[Function]' || val === '[Circular]'
? val
: JSON.stringify(val); // string
}

@@ -393,3 +421,5 @@ return val;

--length;
str += '\n ' + repeat(' ', space) +
str +=
'\n ' +
repeat(' ', space) +
(Array.isArray(object) ? '' : '"' + i + '": ') + // key

@@ -400,5 +430,7 @@ _stringify(object[i]) + // value

return str +
return (
str +
// [], {}
(str.length !== 1 ? '\n' + repeat(' ', --space) + end : end);
(str.length !== 1 ? '\n' + repeat(' ', --space) + end : end)
);
}

@@ -425,3 +457,3 @@

*/
exports.canonicalize = function canonicalize (value, stack, typeHint) {
exports.canonicalize = function canonicalize(value, stack, typeHint) {
var canonicalizedObj;

@@ -432,3 +464,3 @@ /* eslint-disable no-unused-vars */

typeHint = typeHint || type(value);
function withStack (value, fn) {
function withStack(value, fn) {
stack.push(value);

@@ -452,4 +484,4 @@ fn();

case 'array':
withStack(value, function () {
canonicalizedObj = value.map(function (item) {
withStack(value, function() {
canonicalizedObj = value.map(function(item) {
return exports.canonicalize(item, stack);

@@ -473,6 +505,8 @@ });

canonicalizedObj = canonicalizedObj || {};
withStack(value, function () {
Object.keys(value).sort().forEach(function (key) {
canonicalizedObj[key] = exports.canonicalize(value[key], stack);
});
withStack(value, function() {
Object.keys(value)
.sort()
.forEach(function(key) {
canonicalizedObj[key] = exports.canonicalize(value[key], stack);
});
});

@@ -505,3 +539,3 @@ break;

*/
exports.lookupFiles = function lookupFiles (filepath, extensions, recursive) {
exports.lookupFiles = function lookupFiles(filepath, extensions, recursive) {
var files = [];

@@ -531,3 +565,3 @@

fs.readdirSync(filepath).forEach(function (file) {
fs.readdirSync(filepath).forEach(function(file) {
file = path.join(filepath, file);

@@ -546,2 +580,7 @@ try {

}
if (!extensions) {
throw new Error(
'extensions parameter required when filepath is a directory'
);
}
var re = new RegExp('\\.(?:' + extensions.join('|') + ')$');

@@ -563,4 +602,6 @@ if (!stat.isFile() || !re.test(file) || path.basename(file)[0] === '.') {

exports.undefinedError = function () {
return new Error('Caught undefined error, did you throw without specifying what?');
exports.undefinedError = function() {
return new Error(
'Caught undefined error, did you throw without specifying what?'
);
};

@@ -575,3 +616,3 @@

exports.getError = function (err) {
exports.getError = function(err) {
return err || exports.undefinedError();

@@ -589,5 +630,5 @@ };

*/
exports.stackTraceFilter = function () {
exports.stackTraceFilter = function() {
// TODO: Replace with `process.browser`
var is = typeof document === 'undefined' ? { node: true } : { browser: true };
var is = typeof document === 'undefined' ? {node: true} : {browser: true};
var slash = path.sep;

@@ -600,26 +641,31 @@ var cwd;

? window.location
: location).href.replace(/\/[^/]*$/, '/');
: location
).href.replace(/\/[^/]*$/, '/');
slash = '/';
}
function isMochaInternal (line) {
return (~line.indexOf('node_modules' + slash + 'mocha' + slash)) ||
(~line.indexOf('node_modules' + slash + 'mocha.js')) ||
(~line.indexOf('bower_components' + slash + 'mocha.js')) ||
(~line.indexOf(slash + 'mocha.js'));
function isMochaInternal(line) {
return (
~line.indexOf('node_modules' + slash + 'mocha' + slash) ||
~line.indexOf('node_modules' + slash + 'mocha.js') ||
~line.indexOf('bower_components' + slash + 'mocha.js') ||
~line.indexOf(slash + 'mocha.js')
);
}
function isNodeInternal (line) {
return (~line.indexOf('(timers.js:')) ||
(~line.indexOf('(events.js:')) ||
(~line.indexOf('(node.js:')) ||
(~line.indexOf('(module.js:')) ||
(~line.indexOf('GeneratorFunctionPrototype.next (native)')) ||
false;
function isNodeInternal(line) {
return (
~line.indexOf('(timers.js:') ||
~line.indexOf('(events.js:') ||
~line.indexOf('(node.js:') ||
~line.indexOf('(module.js:') ||
~line.indexOf('GeneratorFunctionPrototype.next (native)') ||
false
);
}
return function (stack) {
return function(stack) {
stack = stack.split('\n');
stack = stack.reduce(function (list, line) {
stack = stack.reduce(function(list, line) {
if (isMochaInternal(line)) {

@@ -652,3 +698,3 @@ return list;

*/
exports.isPromise = function isPromise (value) {
exports.isPromise = function isPromise(value) {
return typeof value === 'object' && typeof value.then === 'function';

@@ -661,2 +707,2 @@ };

*/
exports.noop = function () {};
exports.noop = function() {};
{
"name": "mocha",
"version": "5.1.1",
"version": "5.2.0",
"description": "simple, flexible, fun test framework",

@@ -110,4 +110,6 @@ "keywords": [

"David Neubauer <davidneub@gmail.com>",
"DavNej <davnej.dev@gmail.com>",
"Denis Bardadym <bardadymchik@gmail.com>",
"Devin Weaver <suki@tritarget.org>",
"dfberry <dinaberry@outlook.com>",
"Di Wu <dwu@palantir.com>",

@@ -303,2 +305,3 @@ "Dina Berry <dfberry@users.noreply.github.com>",

"Nick Fitzgerald <fitzgen@gmail.com>",
"Nicolas Girault <nic.girault@gmail.com>",
"Nicolo Taddei <taddei.uk@gmail.com>",

@@ -456,7 +459,8 @@ "Nik Nyby <nnyby@columbia.edu>",

"start": "nps",
"test": "nps test"
"test": "nps test",
"precommit": "lint-staged"
},
"dependencies": {
"browser-stdout": "1.3.1",
"commander": "2.11.0",
"commander": "2.15.1",
"debug": "3.1.0",

@@ -466,38 +470,43 @@ "diff": "3.5.0",

"glob": "7.1.2",
"growl": "1.10.3",
"growl": "1.10.5",
"he": "1.1.1",
"minimatch": "3.0.4",
"mkdirp": "0.5.1",
"supports-color": "4.4.0"
"supports-color": "5.4.0"
},
"devDependencies": {
"assert": "^1.4.1",
"assetgraph-builder": "^5.6.4",
"browserify": "^14.4.0",
"@mocha/docdash": "^1.0.1",
"assetgraph-builder": "^6.2.0",
"browserify": "^16.2.2",
"chai": "^4.1.2",
"coffee-script": "^1.10.0",
"coveralls": "^3.0.0",
"cross-spawn": "^5.1.0",
"documentation": "^5.3.5",
"coveralls": "^3.0.1",
"cross-spawn": "^6.0.5",
"eslint": "^4.19.1",
"eslint-config-prettier": "^2.9.0",
"eslint-config-semistandard": "^12.0.1",
"eslint-config-standard": "^11.0.0",
"eslint-plugin-import": "^2.10.0",
"eslint-plugin-import": "^2.11.0",
"eslint-plugin-node": "^6.0.1",
"eslint-plugin-prettier": "^2.6.0",
"eslint-plugin-promise": "^3.7.0",
"eslint-plugin-standard": "^3.0.1",
"expect.js": "^0.3.1",
"karma": "^1.7.1",
"husky": "^0.14.3",
"jsdoc": "^3.5.5",
"karma": "^2.0.2",
"karma-browserify": "^5.0.5",
"karma-chrome-launcher": "^2.0.0",
"karma-expect": "^1.1.2",
"karma-mocha": "^1.3.0",
"karma-mocha-reporter": "^2.2.4",
"karma-sauce-launcher": "^1.2.0",
"lint-staged": "^7.1.0",
"markdown-toc": "^1.2.0",
"markdownlint-cli": "^0.6.0",
"markdownlint-cli": "^0.8.1",
"nps": "^5.7.1",
"nyc": "^11.2.1",
"nyc": "^11.7.3",
"prettier-eslint-cli": "^4.7.1",
"rimraf": "^2.5.2",
"svgo": "^0.7.2",
"svgo": "^1.0.5",
"through2": "^2.0.1",
"unexpected": "^10.37.7",
"watchify": "^3.7.0"

@@ -524,3 +533,7 @@ },

"homepage": "https://mochajs.org",
"logo": "https://cldup.com/S9uQ-cOLYz.svg"
"logo": "https://cldup.com/S9uQ-cOLYz.svg",
"prettier": {
"singleQuote": true,
"bracketSpacing": false
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc