☕️ Classic, reliable, trusted test framework for Node.js and the browser
use semistandard
Christiand62b2b88befa
diff --git a/.eslintrc b/.eslintrcdeleted file mode 100644index d5c733f7..00000000--- a/.eslintrc+++ /dev/null@@ -1,129 +0,0 @@-----env:- node: true--rules:- brace-style: [2, 1tbs]- camelcase: 2- comma-dangle: [2, never]- comma-spacing: [2, {before: false, after: true}]- comma-style: [2, last]- computed-property-spacing: [2, never]- consistent-return: 0- consistent-this: [1, self]- curly: [2, all]- default-case: 2- dot-location: [2, property]- dot-notation: [2, { allowKeywords: true, allowPattern: "^long$" }]- eol-last: 2- eqeqeq: 2- func-style: [2, declaration]- guard-for-in: 2 # TODO: Change to error- handle-callback-err: [2, ^(err|error)$]- indent: [2, 2, { SwitchCase: 1 }]- key-spacing: [2, { beforeColon: false, afterColon: true }]- max-len: [0, 80, 2] # TODO: Change to error- max-params: [1, 4]- new-cap: 0 # TODO: Change to error- new-parens: 2- no-alert: 2- no-array-constructor: 0- no-bitwise: 0- no-caller: 2- no-catch-shadow: 2- no-cond-assign: [1, except-parens] # TODO: Change to error- no-console: 0- no-constant-condition: 0- no-control-regex: 2- no-debugger: 1- no-delete-var: 2- no-dupe-args: 2- no-dupe-keys: 2- no-duplicate-case: 2- no-else-return: 2- no-empty: 2- no-empty-character-class: 2- no-eq-null: 0- no-eval: 2- no-ex-assign: 2- no-extend-native: 2- no-extra-bind: 2- no-extra-boolean-cast: 2- no-extra-semi: 2- no-fallthrough: 2- no-floating-decimal: 0- no-func-assign: 2- no-implied-eval: 2- no-inner-declarations: [2, functions]- no-invalid-regexp: 2- no-irregular-whitespace: 2- no-iterator: 2- no-labels: 2- no-lone-blocks: 2- no-lonely-if: 2- no-loop-func: 2- no-mixed-requires: [0, false]- no-mixed-spaces-and-tabs: [2, false]- no-multi-spaces: 2- no-multi-str: 2- no-multiple-empty-lines: [2, { max: 1 }]- no-native-reassign: 2- no-negated-in-lhs: 2- no-nested-ternary: 2- no-new: 2- no-new-func: 2- no-new-object: 2- no-new-require: 2- no-new-wrappers: 2- no-obj-calls: 2- no-octal: 2- no-octal-escape: 2- no-path-concat: 2- no-process-exit: 2- no-proto: 1 # TODO: Change to error- no-redeclare: 2- no-regex-spaces: 2- no-return-assign: 2- no-script-url: 2- no-self-compare: 2- no-sequences: 2- no-shadow: 0- no-shadow-restricted-names: 2- no-spaced-func: 2- no-sparse-arrays: 2- no-trailing-spaces: 2- no-undef: 2- no-undef-init: 2- no-underscore-dangle: 0 # TODO: Change to error- no-unneeded-ternary: 2- no-unreachable: 2- no-unused-expressions: 0- no-unused-vars: [2, { vars: all, args: after-used }]- no-use-before-define: 0- no-void: 2- no-with: 2- object-curly-spacing: [2, always]- one-var: [2, never]- operator-assignment: [2, always]- operator-linebreak: [2, before]- padded-blocks: [2, never]- quote-props: [2, as-needed]- quotes: [2, single, avoid-escape]- radix: 2- semi: [2, always]- semi-spacing: [2, { before: false, after: true }]- space-before-blocks: [2, always]- space-before-function-paren: [2, never]- space-in-parens: [2, never]- space-infix-ops: 2- keyword-spacing: 2- space-unary-ops: [2, { words: true, nonwords: false }]- spaced-comment: [2, always, { exceptions: ['!'] }]- strict: [0, global] # TODO: Change to error- use-isnan: 2- valid-jsdoc: [0, { requireReturn: false }] # TODO: Change to warning- valid-typeof: 2- vars-on-top: 0- wrap-iife: 2- wrap-regex: 2- yoda: [2, never]diff --git a/.eslintrc.js b/.eslintrc.jsnew file mode 100644index 00000000..71f9d63a--- /dev/null+++ b/.eslintrc.js@@ -0,0 +1,3 @@+module.exports = {+ "extends": "semistandard"+};diff --git a/bin/_mocha b/bin/_mochaindex b355e283..3b2db172 100755--- a/bin/_mocha+++ b/bin/_mocha@@ -114,7 +114,7 @@ program._name = 'mocha';program.command('init <path>').description('initialize a client-side mocha setup at <path>')- .action(function(path) {+ .action(function (path) {var mkdir = require('mkdirp');mkdir.sync(path);var css = fs.readFileSync(join(__dirname, '..', 'mocha.css'));@@ -129,13 +129,13 @@ program// --globals-program.on('globals', function(val) {+program.on('globals', function (val) {globals = globals.concat(list(val));});// --reporters-program.on('reporters', function() {+program.on('reporters', function () {console.log();console.log(' dot - dot matrix');console.log(' doc - html documentation');@@ -156,9 +156,9 @@ program.on('reporters', function() {// --interfaces-program.on('interfaces', function() {+program.on('interfaces', function () {console.log('');- interfaceNames.forEach(function(interfaceName) {+ interfaceNames.forEach(function (interfaceName) {console.log(' ' + interfaceName);});console.log('');@@ -169,7 +169,7 @@ program.on('interfaces', function() {module.paths.push(cwd, join(cwd, 'node_modules'));-program.on('require', function(mod) {+program.on('require', function (mod) {var abs = exists(mod) || exists(mod + '.js');if (abs) {mod = resolve(mod);@@ -194,7 +194,7 @@ Error.stackTraceLimit = Infinity; // TODO: configvar reporterOptions = {};if (program.reporterOptions !== undefined) {- program.reporterOptions.split(',').forEach(function(opt) {+ program.reporterOptions.split(',').forEach(function (opt) {var L = opt.split('=');if (L.length > 2 || L.length === 0) {throw new Error("invalid reporter option '" + opt + "'");@@ -324,7 +324,7 @@ if (program.retries) {// custom compiler supportvar extensions = ['js'];-program.compilers.forEach(function(c) {+program.compilers.forEach(function (c) {var idx = c.indexOf(':');var ext = c.slice(0, idx);var mod = c.slice(idx + 1);@@ -339,7 +339,7 @@ program.compilers.forEach(function(c) {// requires-requires.forEach(function(mod) {+requires.forEach(function (mod) {require(mod);});@@ -357,7 +357,7 @@ if (!args.length) {args.push('test');}-args.forEach(function(arg) {+args.forEach(function (arg) {var newFiles;try {newFiles = utils.lookupFiles(arg, extensions, program.recursive);@@ -380,7 +380,7 @@ if (!files.length) {// resolve-files = files.map(function(path) {+files = files.map(function (path) {return resolve(path);});@@ -398,7 +398,7 @@ var rerun;if (program.watch) {console.log();hideCursor();- process.on('SIGINT', function() {+ process.on('SIGINT', function () {showCursor();console.log('\n');process.exit(130);@@ -407,11 +407,11 @@ if (program.watch) {var watchFiles = utils.files(cwd, [ 'js' ].concat(program.watchExtensions));var runAgain = false;- loadAndRun = function loadAndRun() {+ loadAndRun = function loadAndRun () {try {mocha.files = files;runAgain = false;- runner = mocha.run(function() {+ runner = mocha.run(function () {runner = null;if (runAgain) {rerun();@@ -422,15 +422,15 @@ if (program.watch) {}};- purge = function purge() {- watchFiles.forEach(function(file) {+ purge = function purge () {+ watchFiles.forEach(function (file) {delete require.cache[file];});};loadAndRun();- rerun = function rerun() {+ rerun = function rerun () {purge();stop();if (!program.grep) {@@ -442,7 +442,7 @@ if (program.watch) {loadAndRun();};- utils.watch(watchFiles, function() {+ utils.watch(watchFiles, function () {runAgain = true;if (runner) {runner.abort();@@ -457,17 +457,17 @@ if (program.watch) {runner = mocha.run(program.exit ? exit : exitLater);}-function exitLater(code) {- process.on('exit', function() {+function exitLater (code) {+ process.on('exit', function () {process.exit(Math.min(code, 255));});}-function exit(code) {+function exit (code) {// flush output for Node.js Windows pipe bug// https://github.com/joyent/node/issues/6247 is just one bug example// https://github.com/visionmedia/mocha/issues/333 has a good discussion- function done() {+ function done () {if (!(draining--)) {process.exit(Math.min(code, 255));}@@ -476,7 +476,7 @@ function exit(code) {var draining = 0;var streams = [process.stdout, process.stderr];- streams.forEach(function(stream) {+ streams.forEach(function (stream) {// submit empty write request and wait for completiondraining += 1;stream.write('', done);@@ -485,7 +485,7 @@ function exit(code) {done();}-process.on('SIGINT', function() {+process.on('SIGINT', function () {runner.abort();// This is a hack:@@ -498,7 +498,7 @@ process.on('SIGINT', function() {* Parse list.*/-function list(str) {+function list (str) {return str.split(/ *, */);}@@ -506,7 +506,7 @@ function list(str) {* Hide the cursor.*/-function hideCursor() {+function hideCursor () {process.stdout.write('\u001b[?25l');}@@ -514,7 +514,7 @@ function hideCursor() {* Show the cursor.*/-function showCursor() {+function showCursor () {process.stdout.write('\u001b[?25h');}@@ -522,7 +522,7 @@ function showCursor() {* Stop play()ing.*/-function stop() {+function stop () {process.stdout.write('\u001b[2K');clearInterval(play.timer);}@@ -531,12 +531,12 @@ function stop() {* Play the given array of strings.*/-function play(arr, interval) {+function play (arr, interval) {var len = arr.length;interval = interval || 100;var i = 0;- play.timer = setInterval(function() {+ play.timer = setInterval(function () {var str = arr[i++ % len];process.stdout.write('\u001b[0G' + str);}, interval);diff --git a/bin/mocha b/bin/mochaindex 0c16f0ee..1d5c205b 100755--- a/bin/mocha+++ b/bin/mocha@@ -14,7 +14,7 @@ var args = [path.join(__dirname, '_mocha')];// Must be loaded here to handle node-specific optionsgetOptions();-process.argv.slice(2).forEach(function(arg) {+process.argv.slice(2).forEach(function (arg) {var flag = arg.split('=')[0];switch (flag) {@@ -64,8 +64,8 @@ process.argv.slice(2).forEach(function(arg) {});var proc = spawn(process.execPath, args, { stdio: 'inherit' });-proc.on('exit', function(code, signal) {- process.on('exit', function() {+proc.on('exit', function (code, signal) {+ process.on('exit', function () {if (signal) {process.kill(process.pid, signal);} else {@@ -75,7 +75,7 @@ proc.on('exit', function(code, signal) {});// terminate children.-process.on('SIGINT', function() {+process.on('SIGINT', function () {proc.kill('SIGINT'); // calls runner.abort()proc.kill('SIGTERM'); // if that didn't work, we're probably in an infinite loop, so make it die.});diff --git a/browser-entry.js b/browser-entry.jsindex 789e686a..5fe416da 100644--- a/browser-entry.js+++ b/browser-entry.js@@ -35,12 +35,12 @@ var originalOnerrorHandler = global.onerror;* Revert to original onerror handler if previously defined.*/-process.removeListener = function(e, fn) {+process.removeListener = function (e, fn) {if (e === 'uncaughtException') {if (originalOnerrorHandler) {global.onerror = originalOnerrorHandler;} else {- global.onerror = function() {};+ global.onerror = function () {};}var i = Mocha.utils.indexOf(uncaughtExceptionHandlers, fn);if (i !== -1) {@@ -53,9 +53,9 @@ process.removeListener = function(e, fn) {* Implements uncaughtException listener.*/-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 + ')'));return !mocha.allowUncaught;};@@ -71,7 +71,7 @@ mocha.suite.removeAllListeners('pre-require');var immediateQueue = [];var immediateTimeout;-function timeslice() {+function timeslice () {var immediateStart = new Date().getTime();while (immediateQueue.length && (new Date().getTime() - immediateStart) < 100) {immediateQueue.shift()();@@ -87,7 +87,7 @@ function timeslice() {* High-performance override of Runner.immediately.*/-Mocha.Runner.immediately = function(callback) {+Mocha.Runner.immediately = function (callback) {immediateQueue.push(callback);if (!immediateTimeout) {immediateTimeout = setTimeout(timeslice, 0);@@ -99,8 +99,8 @@ Mocha.Runner.immediately = function(callback) {* This is useful when running tests in a browser because window.onerror will* only receive the 'message' attribute of the Error.*/-mocha.throwError = function(err) {- Mocha.utils.forEach(uncaughtExceptionHandlers, function(fn) {+mocha.throwError = function (err) {+ Mocha.utils.forEach(uncaughtExceptionHandlers, function (fn) {fn(err);});throw err;@@ -111,7 +111,7 @@ mocha.throwError = function(err) {* Normally this would happen in Mocha.prototype.loadFiles.*/-mocha.ui = function(ui) {+mocha.ui = function (ui) {Mocha.prototype.ui.call(this, ui);this.suite.emit('pre-require', global, null, this);return this;@@ -121,7 +121,7 @@ mocha.ui = function(ui) {* Setup mocha with the given setting options.*/-mocha.setup = function(opts) {+mocha.setup = function (opts) {if (typeof opts === 'string') {opts = { ui: opts };}@@ -137,7 +137,7 @@ mocha.setup = function(opts) {* Run mocha, returning the Runner.*/-mocha.run = function(fn) {+mocha.run = function (fn) {var options = mocha.options;mocha.globals('location');@@ -152,7 +152,7 @@ mocha.run = function(fn) {mocha.invert();}- 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) {diff --git a/karma.conf.js b/karma.conf.jsindex 4aa108b2..72161a06 100644--- a/karma.conf.js+++ b/karma.conf.js@@ -5,7 +5,7 @@ var path = require('path');var mkdirp = require('mkdirp');var baseBundleDirpath = path.join(__dirname, '.karma');-module.exports = function(config) {+module.exports = function (config) {var bundleDirpath;var cfg = {frameworks: [@@ -31,12 +31,12 @@ module.exports = function(config) {},browserify: {debug: true,- configure: function configure(b) {+ configure: function configure (b) {b.ignore('glob').ignore('fs').ignore('path').ignore('supports-color')- .on('bundled', function(err, content) {+ .on('bundled', function (err, content) {if (!err && bundleDirpath) {// write bundle to directory for debuggingfs.writeFileSync(path.join(bundleDirpath,@@ -70,8 +70,8 @@ module.exports = function(config) {if (env.SAUCE_USERNAME && env.SAUCE_ACCESS_KEY) {// correlate build/tunnel with TravissauceConfig = {- build: 'TRAVIS #' + env.TRAVIS_BUILD_NUMBER- + ' (' + env.TRAVIS_BUILD_ID + ')',+ build: 'TRAVIS #' + env.TRAVIS_BUILD_NUMBER ++ ' (' + env.TRAVIS_BUILD_ID + ')',tunnelIdentifier: env.TRAVIS_JOB_NUMBER};console.error('Configured SauceLabs');@@ -124,7 +124,7 @@ module.exports = function(config) {config.set(cfg);};-function addSauceTests(cfg) {+function addSauceTests (cfg) {cfg.reporters.push('saucelabs');cfg.customLaunchers = {diff --git a/lib/browser/debug.js b/lib/browser/debug.jsindex ba232896..a4b3b3fd 100644--- a/lib/browser/debug.js+++ b/lib/browser/debug.js@@ -1,4 +1,4 @@/* eslint-disable no-unused-vars */-module.exports = function(type) {- return function() {};+module.exports = function (type) {+ return function () {};};diff --git a/lib/browser/events.js b/lib/browser/events.jsindex b4342f62..5e410a34 100644--- a/lib/browser/events.js+++ b/lib/browser/events.js@@ -16,7 +16,7 @@ var objToString = Object.prototype.toString;* @param {*} val The value to test.* @return {boolean} true if the value is an array, otherwise false.*/-function isArray(val) {+function isArray (val) {return objToString.call(val) === '[object Array]';}@@ -25,7 +25,7 @@ function isArray(val) {** @api public*/-function EventEmitter() {}+function EventEmitter () {}/*** Add a listener.@@ -35,7 +35,7 @@ function EventEmitter() {}* @param {Function} fn Event handler.* @return {EventEmitter} Emitter instance.*/-EventEmitter.prototype.on = function(name, fn) {+EventEmitter.prototype.on = function (name, fn) {if (!this.$events) {this.$events = {};}@@ -61,10 +61,10 @@ EventEmitter.prototype.addListener = EventEmitter.prototype.on;* @param {Function} fn Event handler.* @return {EventEmitter} Emitter instance.*/-EventEmitter.prototype.once = function(name, fn) {+EventEmitter.prototype.once = function (name, fn) {var self = this;- function on() {+ function on () {self.removeListener(name, on);fn.apply(this, arguments);}@@ -83,7 +83,7 @@ EventEmitter.prototype.once = function(name, fn) {* @param {Function} fn Event handler.* @return {EventEmitter} Emitter instance.*/-EventEmitter.prototype.removeListener = function(name, fn) {+EventEmitter.prototype.removeListener = function (name, fn) {if (this.$events && this.$events[name]) {var list = this.$events[name];@@ -121,7 +121,7 @@ EventEmitter.prototype.removeListener = function(name, fn) {* @param {string} name Event name.* @return {EventEmitter} Emitter instance.*/-EventEmitter.prototype.removeAllListeners = function(name) {+EventEmitter.prototype.removeAllListeners = function (name) {if (name === undefined) {this.$events = {};return this;@@ -141,7 +141,7 @@ EventEmitter.prototype.removeAllListeners = function(name) {* @param {string} name Event name.* @return {EventEmitter} Emitter instance.*/-EventEmitter.prototype.listeners = function(name) {+EventEmitter.prototype.listeners = function (name) {if (!this.$events) {this.$events = {};}@@ -164,7 +164,7 @@ EventEmitter.prototype.listeners = function(name) {* @param {string} name Event name.* @return {boolean} true if at least one handler was invoked, else false.*/-EventEmitter.prototype.emit = function(name) {+EventEmitter.prototype.emit = function (name) {if (!this.$events) {return false;}diff --git a/lib/browser/progress.js b/lib/browser/progress.jsindex 3186b6ec..e71ba440 100644--- a/lib/browser/progress.js+++ b/lib/browser/progress.js@@ -7,7 +7,7 @@ module.exports = Progress;/*** Initialize a new `Progress` indicator.*/-function Progress() {+function Progress () {this.percent = 0;this.size(0);this.fontSize(11);@@ -21,7 +21,7 @@ function Progress() {* @param {number} size* @return {Progress} Progress instance.*/-Progress.prototype.size = function(size) {+Progress.prototype.size = function (size) {this._size = size;return this;};@@ -33,7 +33,7 @@ Progress.prototype.size = function(size) {* @param {string} text* @return {Progress} Progress instance.*/-Progress.prototype.text = function(text) {+Progress.prototype.text = function (text) {this._text = text;return this;};@@ -45,7 +45,7 @@ Progress.prototype.text = function(text) {* @param {number} size* @return {Progress} Progress instance.*/-Progress.prototype.fontSize = function(size) {+Progress.prototype.fontSize = function (size) {this._fontSize = size;return this;};@@ -56,7 +56,7 @@ Progress.prototype.fontSize = function(size) {* @param {string} family* @return {Progress} Progress instance.*/-Progress.prototype.font = function(family) {+Progress.prototype.font = function (family) {this._font = family;return this;};@@ -67,7 +67,7 @@ Progress.prototype.font = function(family) {* @param {number} n* @return {Progress} Progress instance.*/-Progress.prototype.update = function(n) {+Progress.prototype.update = function (n) {this.percent = n;return this;};@@ -78,7 +78,7 @@ Progress.prototype.update = function(n) {* @param {CanvasRenderingContext2d} ctx* @return {Progress} Progress instance.*/-Progress.prototype.draw = function(ctx) {+Progress.prototype.draw = function (ctx) {try {var percent = Math.min(this.percent, 100);var size = this._size;diff --git a/lib/browser/tty.js b/lib/browser/tty.jsindex 840d6699..7825e1c9 100644--- a/lib/browser/tty.js+++ b/lib/browser/tty.js@@ -1,8 +1,8 @@-exports.isatty = function isatty() {+exports.isatty = function isatty () {return true;};-exports.getWindowSize = function getWindowSize() {+exports.getWindowSize = function getWindowSize () {if ('innerHeight' in global) {return [global.innerHeight, global.innerWidth];}diff --git a/lib/context.js b/lib/context.jsindex 6d82fcad..c049dc54 100644--- a/lib/context.js+++ b/lib/context.js@@ -15,7 +15,7 @@ module.exports = Context;** @api private*/-function Context() {}+function Context () {}/*** Set or get the context `Runnable` to `runnable`.@@ -24,7 +24,7 @@ function Context() {}* @param {Runnable} runnable* @return {Context}*/-Context.prototype.runnable = function(runnable) {+Context.prototype.runnable = function (runnable) {if (!arguments.length) {return this._runnable;}@@ -39,7 +39,7 @@ Context.prototype.runnable = function(runnable) {* @param {number} ms* @return {Context} self*/-Context.prototype.timeout = function(ms) {+Context.prototype.timeout = function (ms) {if (!arguments.length) {return this.runnable().timeout();}@@ -54,7 +54,7 @@ Context.prototype.timeout = function(ms) {* @param {boolean} enabled* @return {Context} self*/-Context.prototype.enableTimeouts = function(enabled) {+Context.prototype.enableTimeouts = function (enabled) {this.runnable().enableTimeouts(enabled);return this;};@@ -66,7 +66,7 @@ Context.prototype.enableTimeouts = function(enabled) {* @param {number} ms* @return {Context} self*/-Context.prototype.slow = function(ms) {+Context.prototype.slow = function (ms) {this.runnable().slow(ms);return this;};@@ -77,7 +77,7 @@ Context.prototype.slow = function(ms) {* @api private* @return {Context} self*/-Context.prototype.skip = function() {+Context.prototype.skip = function () {this.runnable().skip();return this;};@@ -89,7 +89,7 @@ Context.prototype.skip = function() {* @param {number} n* @return {Context} self*/-Context.prototype.retries = function(n) {+Context.prototype.retries = function (n) {if (!arguments.length) {return this.runnable().retries();}@@ -103,8 +103,8 @@ Context.prototype.retries = function(n) {* @api private* @return {string}*/-Context.prototype.inspect = function() {- return JSON.stringify(this, function(key, val) {+Context.prototype.inspect = function () {+ return JSON.stringify(this, function (key, val) {return key === 'runnable' || key === 'test' ? undefined : val;}, 2);};diff --git a/lib/hook.js b/lib/hook.jsindex 0417e013..54260198 100644--- a/lib/hook.js+++ b/lib/hook.js@@ -18,7 +18,7 @@ module.exports = Hook;* @param {Function} fn* @api private*/-function Hook(title, fn) {+function Hook (title, fn) {Runnable.call(this, title, fn);this.type = 'hook';}@@ -35,7 +35,7 @@ inherits(Hook, Runnable);* @return {Error}* @api public*/-Hook.prototype.error = function(err) {+Hook.prototype.error = function (err) {if (!arguments.length) {err = this._error;this._error = null;diff --git a/lib/interfaces/bdd.js b/lib/interfaces/bdd.jsindex 830a5fe6..289f9379 100644--- a/lib/interfaces/bdd.js+++ b/lib/interfaces/bdd.js@@ -21,10 +21,10 @@ var Test = require('../test');** @param {Suite} suite Root suite.*/-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);context.before = common.before;@@ -38,7 +38,7 @@ module.exports = function(suite) {* and/or tests.*/- context.describe = context.context = function(title, fn) {+ context.describe = context.context = function (title, fn) {return common.suite.create({title: title,file: file,@@ -50,7 +50,7 @@ module.exports = function(suite) {* Pending describe.*/- context.xdescribe = context.xcontext = context.describe.skip = function(title, fn) {+ context.xdescribe = context.xcontext = context.describe.skip = function (title, fn) {return common.suite.skip({title: title,file: file,@@ -62,7 +62,7 @@ module.exports = function(suite) {* Exclusive suite.*/- context.describe.only = function(title, fn) {+ context.describe.only = function (title, fn) {return common.suite.only({title: title,file: file,@@ -76,7 +76,7 @@ module.exports = function(suite) {* acting as a thunk.*/- context.it = context.specify = function(title, fn) {+ context.it = context.specify = function (title, fn) {var suite = suites[0];if (suite.isPending()) {fn = null;@@ -91,7 +91,7 @@ module.exports = function(suite) {* Exclusive test-case.*/- context.it.only = function(title, fn) {+ context.it.only = function (title, fn) {return common.test.only(mocha, context.it(title, fn));};@@ -99,14 +99,14 @@ module.exports = function(suite) {* Pending test case.*/- context.xit = context.xspecify = context.it.skip = function(title) {+ context.xit = context.xspecify = context.it.skip = function (title) {context.it(title);};/*** Number of attempts to retry.*/- context.it.retries = function(n) {+ context.it.retries = function (n) {context.retries(n);};});diff --git a/lib/interfaces/common.js b/lib/interfaces/common.jsindex 44745848..aec6b0d2 100644--- a/lib/interfaces/common.js+++ b/lib/interfaces/common.js@@ -10,7 +10,7 @@ var Suite = require('../suite');* @param {Mocha} mocha* @return {Object} An object containing common functions.*/-module.exports = function(suites, context, mocha) {+module.exports = function (suites, context, mocha) {return {/*** This is only present if flag --delay is passed into Mocha. It triggers@@ -19,8 +19,8 @@ module.exports = function(suites, context, mocha) {* @param {Suite} suite The root wuite.* @return {Function} A function which runs the root suite*/- runWithSuite: function runWithSuite(suite) {- return function run() {+ runWithSuite: function runWithSuite (suite) {+ return function run () {suite.run();};},@@ -31,7 +31,7 @@ module.exports = function(suites, context, mocha) {* @param {string} name* @param {Function} fn*/- before: function(name, fn) {+ before: function (name, fn) {suites[0].beforeAll(name, fn);},@@ -41,7 +41,7 @@ module.exports = function(suites, context, mocha) {* @param {string} name* @param {Function} fn*/- after: function(name, fn) {+ after: function (name, fn) {suites[0].afterAll(name, fn);},@@ -51,7 +51,7 @@ module.exports = function(suites, context, mocha) {* @param {string} name* @param {Function} fn*/- beforeEach: function(name, fn) {+ beforeEach: function (name, fn) {suites[0].beforeEach(name, fn);},@@ -61,7 +61,7 @@ module.exports = function(suites, context, mocha) {* @param {string} name* @param {Function} fn*/- afterEach: function(name, fn) {+ afterEach: function (name, fn) {suites[0].afterEach(name, fn);},@@ -73,7 +73,7 @@ module.exports = function(suites, context, mocha) {* @param {Object} opts* @returns {Suite}*/- only: function only(opts) {+ only: function only (opts) {mocha.options.hasOnly = true;opts.isOnly = true;return this.create(opts);@@ -86,7 +86,7 @@ module.exports = function(suites, context, mocha) {* @param {Object} opts* @returns {Suite}*/- skip: function skip(opts) {+ skip: function skip (opts) {opts.pending = true;return this.create(opts);},@@ -101,7 +101,7 @@ module.exports = function(suites, context, mocha) {* @param {boolean} [opts.isOnly] Is Suite exclusive?* @returns {Suite}*/- create: function create(opts) {+ create: function create (opts) {var suite = Suite.create(suites[0], opts.title);suite.pending = Boolean(opts.pending);suite.file = opts.file;@@ -130,7 +130,7 @@ module.exports = function(suites, context, mocha) {* @param {Function} test* @returns {*}*/- only: function(mocha, test) {+ only: function (mocha, test) {test.parent._onlyTests = test.parent._onlyTests.concat(test);mocha.options.hasOnly = true;return test;@@ -141,7 +141,7 @@ module.exports = function(suites, context, mocha) {** @param {string} title*/- skip: function(title) {+ skip: function (title) {context.test(title);},@@ -150,7 +150,7 @@ module.exports = function(suites, context, mocha) {** @param {number} n*/- retries: function(n) {+ retries: function (n) {context.retries(n);}}diff --git a/lib/interfaces/exports.js b/lib/interfaces/exports.jsindex 7db6e47c..2bfa3fb4 100644--- a/lib/interfaces/exports.js+++ b/lib/interfaces/exports.js@@ -22,12 +22,12 @@ var Test = require('../test');** @param {Suite} suite Root suite.*/-module.exports = function(suite) {+module.exports = function (suite) {var suites = [suite];suite.on('require', visit);- function visit(obj, file) {+ function visit (obj, file) {var suite;for (var key in obj) {if (typeof obj[key] === 'function') {diff --git a/lib/interfaces/qunit.js b/lib/interfaces/qunit.jsindex 22e8080e..1e567a0a 100644--- a/lib/interfaces/qunit.js+++ b/lib/interfaces/qunit.js@@ -29,10 +29,10 @@ var Test = require('../test');** @param {Suite} suite Root suite.*/-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);context.before = common.before;@@ -44,7 +44,7 @@ module.exports = function(suite) {* Describe a "suite" with the given `title`.*/- context.suite = function(title) {+ context.suite = function (title) {if (suites.length > 1) {suites.shift();}@@ -59,7 +59,7 @@ module.exports = function(suite) {* Exclusive Suite.*/- context.suite.only = function(title) {+ context.suite.only = function (title) {if (suites.length > 1) {suites.shift();}@@ -76,7 +76,7 @@ module.exports = function(suite) {* acting as a thunk.*/- context.test = function(title, fn) {+ context.test = function (title, fn) {var test = new Test(title, fn);test.file = file;suites[0].addTest(test);@@ -87,7 +87,7 @@ module.exports = function(suite) {* Exclusive test-case.*/- context.test.only = function(title, fn) {+ context.test.only = function (title, fn) {return common.test.only(mocha, context.test(title, fn));};diff --git a/lib/interfaces/tdd.js b/lib/interfaces/tdd.jsindex 445e9922..b9802f85 100644--- a/lib/interfaces/tdd.js+++ b/lib/interfaces/tdd.js@@ -29,10 +29,10 @@ var Test = require('../test');** @param {Suite} suite Root suite.*/-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);context.setup = common.beforeEach;@@ -45,7 +45,7 @@ module.exports = function(suite) {* Describe a "suite" with the given `title` and callback `fn` containing* nested suites and/or tests.*/- context.suite = function(title, fn) {+ context.suite = function (title, fn) {return common.suite.create({title: title,file: file,@@ -56,7 +56,7 @@ module.exports = function(suite) {/*** Pending suite.*/- context.suite.skip = function(title, fn) {+ context.suite.skip = function (title, fn) {return common.suite.skip({title: title,file: file,@@ -67,7 +67,7 @@ module.exports = function(suite) {/*** Exclusive test-case.*/- context.suite.only = function(title, fn) {+ context.suite.only = function (title, fn) {return common.suite.only({title: title,file: file,@@ -79,7 +79,7 @@ module.exports = function(suite) {* Describe a specification or test-case with the given `title` and* callback `fn` acting as a thunk.*/- context.test = function(title, fn) {+ context.test = function (title, fn) {var suite = suites[0];if (suite.isPending()) {fn = null;@@ -94,7 +94,7 @@ module.exports = function(suite) {* Exclusive test-case.*/- context.test.only = function(title, fn) {+ context.test.only = function (title, fn) {return common.test.only(mocha, context.test(title, fn));};diff --git a/lib/mocha.js b/lib/mocha.jsindex a6497151..b9232270 100644--- a/lib/mocha.js+++ b/lib/mocha.js@@ -49,7 +49,7 @@ exports.Test = require('./test');* @param {string} name* @return {string}*/-function image(name) {+function image (name) {return path.join(__dirname, '../images', name + '.png');}@@ -72,7 +72,7 @@ function image(name) {* @param {Object} options* @api public*/-function Mocha(options) {+function Mocha (options) {options = options || {};this.files = [];this.options = options;@@ -107,7 +107,7 @@ function Mocha(options) {* @api public* @param {boolean} [bail]*/-Mocha.prototype.bail = function(bail) {+Mocha.prototype.bail = function (bail) {if (!arguments.length) {bail = true;}@@ -121,7 +121,7 @@ Mocha.prototype.bail = function(bail) {* @api public* @param {string} file*/-Mocha.prototype.addFile = function(file) {+Mocha.prototype.addFile = function (file) {this.files.push(file);return this;};@@ -135,7 +135,7 @@ Mocha.prototype.addFile = function(file) {* @param {string|Function} reporter name or constructor* @param {Object} reporterOptions optional options*/-Mocha.prototype.reporter = function(reporter, reporterOptions) {+Mocha.prototype.reporter = function (reporter, reporterOptions) {if (typeof reporter === 'function') {this._reporter = reporter;} else {@@ -156,9 +156,9 @@ Mocha.prototype.reporter = function(reporter, reporterOptions) {}}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).');}if (!_reporter) {throw new Error('invalid reporter "' + reporter + '"');@@ -175,7 +175,7 @@ Mocha.prototype.reporter = function(reporter, reporterOptions) {* @api public* @param {string} bdd*/-Mocha.prototype.ui = function(name) {+Mocha.prototype.ui = function (name) {name = name || 'bdd';this._ui = exports.interfaces[name];if (!this._ui) {@@ -187,7 +187,7 @@ Mocha.prototype.ui = function(name) {}this._ui = this._ui(this.suite);- this.suite.on('pre-require', function(context) {+ this.suite.on('pre-require', function (context) {exports.afterEach = context.afterEach || context.teardown;exports.after = context.after || context.suiteTeardown;exports.beforeEach = context.beforeEach || context.setup;@@ -211,10 +211,10 @@ Mocha.prototype.ui = function(name) {** @api private*/-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);suite.emit('pre-require', global, file, self);suite.emit('require', require(file), file, self);@@ -228,10 +228,10 @@ Mocha.prototype.loadFiles = function(fn) {** @api private*/-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';@@ -253,7 +253,7 @@ Mocha.prototype._growl = function(runner, reporter) {* @param str* @returns {Mocha}*/-Mocha.prototype.fgrep = function(str) {+Mocha.prototype.fgrep = function (str) {return this.grep(new RegExp(escapeRe(str)));};@@ -266,7 +266,7 @@ Mocha.prototype.fgrep = function(str) {* @param {RegExp|string} re* @return {Mocha}*/-Mocha.prototype.grep = function(re) {+Mocha.prototype.grep = function (re) {if (utils.isString(re)) {// extract args if it's regex-like, i.e: [string, pattern, flag]var arg = re.match(/^\/(.*)\/(g|i|)$|.*/);@@ -282,7 +282,7 @@ Mocha.prototype.grep = function(re) {* @return {Mocha}* @api public*/-Mocha.prototype.invert = function() {+Mocha.prototype.invert = function () {this.options.invert = true;return this;};@@ -296,7 +296,7 @@ Mocha.prototype.invert = function() {* @param {boolean} ignore* @return {Mocha}*/-Mocha.prototype.ignoreLeaks = function(ignore) {+Mocha.prototype.ignoreLeaks = function (ignore) {this.options.ignoreLeaks = Boolean(ignore);return this;};@@ -307,7 +307,7 @@ Mocha.prototype.ignoreLeaks = function(ignore) {* @return {Mocha}* @api public*/-Mocha.prototype.checkLeaks = function() {+Mocha.prototype.checkLeaks = function () {this.options.ignoreLeaks = false;return this;};@@ -318,7 +318,7 @@ Mocha.prototype.checkLeaks = function() {* @return {Mocha}* @api public*/-Mocha.prototype.fullTrace = function() {+Mocha.prototype.fullTrace = function () {this.options.fullStackTrace = true;return this;};@@ -329,7 +329,7 @@ Mocha.prototype.fullTrace = function() {* @return {Mocha}* @api public*/-Mocha.prototype.growl = function() {+Mocha.prototype.growl = function () {this.options.growl = true;return this;};@@ -343,7 +343,7 @@ Mocha.prototype.growl = function() {* @param {Array|string} globals* @return {Mocha}*/-Mocha.prototype.globals = function(globals) {+Mocha.prototype.globals = function (globals) {this.options.globals = (this.options.globals || []).concat(globals);return this;};@@ -357,7 +357,7 @@ Mocha.prototype.globals = function(globals) {* @param {boolean} colors* @return {Mocha}*/-Mocha.prototype.useColors = function(colors) {+Mocha.prototype.useColors = function (colors) {if (colors !== undefined) {this.options.useColors = colors;}@@ -373,7 +373,7 @@ Mocha.prototype.useColors = function(colors) {* @param {boolean} inlineDiffs* @return {Mocha}*/-Mocha.prototype.useInlineDiffs = function(inlineDiffs) {+Mocha.prototype.useInlineDiffs = function (inlineDiffs) {this.options.useInlineDiffs = inlineDiffs !== undefined && inlineDiffs;return this;};@@ -387,7 +387,7 @@ Mocha.prototype.useInlineDiffs = function(inlineDiffs) {* @param {number} timeout* @return {Mocha}*/-Mocha.prototype.timeout = function(timeout) {+Mocha.prototype.timeout = function (timeout) {this.suite.timeout(timeout);return this;};@@ -399,7 +399,7 @@ Mocha.prototype.timeout = function(timeout) {* @return {Mocha}* @api public*/-Mocha.prototype.retries = function(n) {+Mocha.prototype.retries = function (n) {this.suite.retries(n);return this;};@@ -413,7 +413,7 @@ Mocha.prototype.retries = function(n) {* @param {number} slow* @return {Mocha}*/-Mocha.prototype.slow = function(slow) {+Mocha.prototype.slow = function (slow) {this.suite.slow(slow);return this;};@@ -427,7 +427,7 @@ Mocha.prototype.slow = function(slow) {* @param {boolean} enabled* @return {Mocha}*/-Mocha.prototype.enableTimeouts = function(enabled) {+Mocha.prototype.enableTimeouts = function (enabled) {this.suite.enableTimeouts(arguments.length && enabled !== undefined ? enabled : true);return this;};@@ -438,7 +438,7 @@ Mocha.prototype.enableTimeouts = function(enabled) {* @return {Mocha}* @api public*/-Mocha.prototype.asyncOnly = function() {+Mocha.prototype.asyncOnly = function () {this.options.asyncOnly = true;return this;};@@ -448,7 +448,7 @@ Mocha.prototype.asyncOnly = function() {** @api public*/-Mocha.prototype.noHighlighting = function() {+Mocha.prototype.noHighlighting = function () {this.options.noHighlighting = true;return this;};@@ -459,7 +459,7 @@ Mocha.prototype.noHighlighting = function() {* @return {Mocha}* @api public*/-Mocha.prototype.allowUncaught = function() {+Mocha.prototype.allowUncaught = function () {this.options.allowUncaught = true;return this;};@@ -468,7 +468,7 @@ Mocha.prototype.allowUncaught = function() {* Delay root suite execution.* @returns {Mocha}*/-Mocha.prototype.delay = function delay() {+Mocha.prototype.delay = function delay () {this.options.delay = true;return this;};@@ -480,7 +480,7 @@ Mocha.prototype.delay = function delay() {* @param {Function} fn* @return {Runner}*/-Mocha.prototype.run = function(fn) {+Mocha.prototype.run = function (fn) {if (this.files.length) {this.loadFiles();}@@ -508,7 +508,7 @@ Mocha.prototype.run = function(fn) {}exports.reporters.Base.inlineDiffs = options.useInlineDiffs;- function done(failures) {+ function done (failures) {if (reporter.done) {reporter.done(failures, fn);} else {diff --git a/lib/ms.js b/lib/ms.jsindex 12fddc18..fed85f8c 100644--- a/lib/ms.js+++ b/lib/ms.js@@ -20,7 +20,7 @@ var y = d * 365.25;* @param {Object} options* @return {string|number}*/-module.exports = function(val, options) {+module.exports = function (val, options) {options = options || {};if (typeof val === 'string') {return parse(val);@@ -36,7 +36,7 @@ module.exports = function(val, options) {* @param {string} str* @return {number}*/-function parse(str) {+function parse (str) {var match = (/^((?:\d+)?\.?\d+) *(ms|seconds?|s|minutes?|m|hours?|h|days?|d|years?|y)?$/i).exec(str);if (!match) {return;@@ -78,7 +78,7 @@ function parse(str) {* @param {number} ms* @return {string}*/-function shortFormat(ms) {+function shortFormat (ms) {if (ms >= d) {return Math.round(ms / d) + 'd';}@@ -101,12 +101,12 @@ function shortFormat(ms) {* @param {number} ms* @return {string}*/-function longFormat(ms) {- return plural(ms, d, 'day')- || plural(ms, h, 'hour')- || plural(ms, m, 'minute')- || plural(ms, s, 'second')- || ms + ' ms';+function longFormat (ms) {+ return plural(ms, d, 'day') ||+ plural(ms, h, 'hour') ||+ plural(ms, m, 'minute') ||+ plural(ms, s, 'second') ||+ ms + ' ms';}/**@@ -117,7 +117,7 @@ function longFormat(ms) {* @param {number} n* @param {string} name*/-function plural(ms, n, name) {+function plural (ms, n, name) {if (ms < n) {return;}diff --git a/lib/pending.js b/lib/pending.jsindex c847e04e..47be3769 100644--- a/lib/pending.js+++ b/lib/pending.js@@ -10,6 +10,6 @@ module.exports = Pending;** @param {string} message*/-function Pending(message) {+function Pending (message) {this.message = message;}diff --git a/lib/reporters/base.js b/lib/reporters/base.jsindex c754c523..df201ef6 100644--- a/lib/reporters/base.js+++ b/lib/reporters/base.js@@ -101,7 +101,7 @@ if (process.platform === 'win32') {* @return {string}* @api private*/-var color = exports.color = function(type, str) {+var color = exports.color = function (type, str) {if (!exports.useColors) {return String(str);}@@ -127,23 +127,23 @@ if (isatty) {*/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) {exports.cursor.deleteLine();exports.cursor.beginningOfLine();@@ -160,13 +160,13 @@ exports.cursor = {* @api public*/-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')- + color('error message', ' %s')- + color('error stack', '\n%s\n');+ var fmt = color('error title', ' %s) %s:\n') ++ color('error message', ' %s') ++ color('error stack', '\n%s\n');// msgvar msg;@@ -236,7 +236,7 @@ exports.list = function(failures) {* @api public*/-function Base(runner) {+function Base (runner) {var stats = this.stats = { suites: 0, tests: 0, passes: 0, pending: 0, failures: 0 };var failures = this.failures = [];@@ -247,21 +247,21 @@ function Base(runner) {runner.stats = stats;- 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;suite.root || stats.suites++;});- runner.on('test end', function() {+ runner.on('test end', function () {stats.tests = stats.tests || 0;stats.tests++;});- runner.on('pass', function(test) {+ runner.on('pass', function (test) {stats.passes = stats.passes || 0;if (test.duration > test.slow()) {@@ -275,19 +275,19 @@ function Base(runner) {stats.passes++;});- runner.on('fail', function(test, err) {+ runner.on('fail', function (test, err) {stats.failures = stats.failures || 0;stats.failures++;test.err = err;failures.push(test);});- runner.on('end', function() {+ runner.on('end', function () {stats.end = new Date();stats.duration = new Date() - stats.start;});- runner.on('pending', function() {+ runner.on('pending', function () {stats.pending++;});}@@ -298,16 +298,16 @@ function Base(runner) {** @api public*/-Base.prototype.epilogue = function() {+Base.prototype.epilogue = function () {var stats = this.stats;var fmt;console.log();// passes- fmt = color('bright pass', ' ')- + color('green', ' %d passing')- + color('light', ' (%s)');+ fmt = color('bright pass', ' ') ++ color('green', ' %d passing') ++ color('light', ' (%s)');console.log(fmt,stats.passes || 0,@@ -315,8 +315,8 @@ Base.prototype.epilogue = function() {// pendingif (stats.pending) {- fmt = color('pending', ' ')- + color('pending', ' %d pending');+ fmt = color('pending', ' ') ++ color('pending', ' %d pending');console.log(fmt, stats.pending);}@@ -342,7 +342,7 @@ Base.prototype.epilogue = function() {* @param {string} len* @return {string}*/-function pad(str, len) {+function pad (str, len) {str = String(str);return Array(len - str.length + 1).join(' ') + str;}@@ -355,26 +355,26 @@ function pad(str, len) {* @param {boolean} escape* @return {string} Diff*/-function inlineDiff(err, escape) {+function inlineDiff (err, escape) {var msg = errorDiff(err, 'WordsWithSpace', escape);// linenosvar lines = msg.split('\n');if (lines.length > 4) {var width = String(lines.length).length;- msg = lines.map(function(str, i) {+ msg = lines.map(function (str, i) {return pad(++i, width) + ' |' + ' ' + str;}).join('\n');}// legend- msg = '\n'- + color('diff removed', 'actual')- + ' '- + color('diff added', 'expected')- + '\n\n'- + msg- + '\n';+ msg = '\n' ++ color('diff removed', 'actual') ++ ' ' ++ color('diff added', 'expected') ++ '\n\n' ++ msg ++ '\n';// indentmsg = msg.replace(/^/gm, ' ');@@ -389,9 +389,9 @@ function inlineDiff(err, escape) {* @param {boolean} escape* @return {string} The diff.*/-function unifiedDiff(err, escape) {+function unifiedDiff (err, escape) {var indent = ' ';- function cleanUp(line) {+ function cleanUp (line) {if (escape) {line = escapeInvisibles(line);}@@ -401,7 +401,7 @@ function unifiedDiff(err, escape) {if (line[0] === '-') {return indent + colorLines('diff removed', line);}- if (line.match(/\@\@/)) {+ if (line.match(/@@/)) {return null;}if (line.match(/\\ No newline/)) {@@ -409,16 +409,16 @@ function unifiedDiff(err, escape) {}return indent + line;}- function notBlank(line) {+ function notBlank (line) {return typeof line !== 'undefined' && line !== null;}var msg = diff.createPatch('string', err.actual, err.expected);var lines = msg.split('\n').splice(4);- return '\n '- + colorLines('diff added', '+ expected') + ' '- + colorLines('diff removed', '- actual')- + '\n\n'- + lines.map(cleanUp).filter(notBlank).join('\n');+ return '\n ' ++ colorLines('diff added', '+ expected') + ' ' ++ colorLines('diff removed', '- actual') ++ '\n\n' ++ lines.map(cleanUp).filter(notBlank).join('\n');}/**@@ -430,10 +430,10 @@ function unifiedDiff(err, escape) {* @param {boolean} escape* @return {string}*/-function errorDiff(err, type, escape) {+function errorDiff (err, type, escape) {var actual = escape ? escapeInvisibles(err.actual) : err.actual;var expected = escape ? escapeInvisibles(err.expected) : err.expected;- return diff['diff' + type](actual, expected).map(function(str) {+ return diff['diff' + type](actual, expected).map(function (str) {if (str.added) {return colorLines('diff added', str.value);}@@ -451,7 +451,7 @@ function errorDiff(err, type, escape) {* @param {string} line* @return {string}*/-function escapeInvisibles(line) {+function escapeInvisibles (line) {return line.replace(/\t/g, '<tab>').replace(/\r/g, '<CR>').replace(/\n/g, '<LF>\n');@@ -465,8 +465,8 @@ function escapeInvisibles(line) {* @param {string} str* @return {string}*/-function colorLines(name, str) {- return str.split('\n').map(function(str) {+function colorLines (name, str) {+ return str.split('\n').map(function (str) {return color(name, str);}).join('\n');}@@ -484,6 +484,6 @@ var objToString = Object.prototype.toString;* @param {Object} b* @return {boolean}*/-function sameType(a, b) {+function sameType (a, b) {return objToString.call(a) === objToString.call(b);}diff --git a/lib/reporters/doc.js b/lib/reporters/doc.jsindex 9f5c3f8a..506ce6d6 100644--- a/lib/reporters/doc.js+++ b/lib/reporters/doc.js@@ -17,16 +17,16 @@ exports = module.exports = Doc;* @param {Runner} runner* @api public*/-function Doc(runner) {+function Doc (runner) {Base.call(this, runner);var indents = 2;- function indent() {+ function indent () {return Array(indents).join(' ');}- runner.on('suite', function(suite) {+ runner.on('suite', function (suite) {if (suite.root) {return;}@@ -37,7 +37,7 @@ function Doc(runner) {console.log('%s<dl>', indent());});- runner.on('suite end', function(suite) {+ runner.on('suite end', function (suite) {if (suite.root) {return;}@@ -47,13 +47,13 @@ function Doc(runner) {--indents;});- runner.on('pass', function(test) {+ runner.on('pass', function (test) {console.log('%s <dt>%s</dt>', indent(), utils.escape(test.title));var code = utils.escape(utils.clean(test.body));console.log('%s <dd><pre><code>%s</code></pre></dd>', indent(), code);});- runner.on('fail', function(test, err) {+ 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);diff --git a/lib/reporters/dot.js b/lib/reporters/dot.jsindex f8b4b41f..e2a359ce 100644--- a/lib/reporters/dot.js+++ b/lib/reporters/dot.js@@ -18,25 +18,25 @@ exports = module.exports = Dot;* @api public* @param {Runner} runner*/-function Dot(runner) {+function Dot (runner) {Base.call(this, runner);var self = this;- var width = Base.window.width * .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) {process.stdout.write('\n ');}process.stdout.write(color('pending', Base.symbols.comma));});- runner.on('pass', function(test) {+ runner.on('pass', function (test) {if (++n % width === 0) {process.stdout.write('\n ');}@@ -47,14 +47,14 @@ function Dot(runner) {}});- runner.on('fail', function() {+ runner.on('fail', function () {if (++n % width === 0) {process.stdout.write('\n ');}process.stdout.write(color('fail', Base.symbols.bang));});- runner.on('end', function() {+ runner.on('end', function () {console.log();self.epilogue();});diff --git a/lib/reporters/html.js b/lib/reporters/html.jsindex 51ba1ca7..bf46b5e1 100644--- a/lib/reporters/html.js+++ b/lib/reporters/html.js@@ -32,12 +32,12 @@ exports = module.exports = HTML;* Stats template.*/-var statsTemplate = '<ul id="mocha-stats">'- + '<li class="progress"><canvas width="40" height="40"></canvas></li>'- + '<li class="passes"><a href="javascript:void(0);">passes:</a> <em>0</em></li>'- + '<li class="failures"><a href="javascript:void(0);">failures:</a> <em>0</em></li>'- + '<li class="duration">duration: <em>0</em>s</li>'- + '</ul>';+var statsTemplate = '<ul id="mocha-stats">' ++ '<li class="progress"><canvas width="40" height="40"></canvas></li>' ++ '<li class="passes"><a href="javascript:void(0);">passes:</a> <em>0</em></li>' ++ '<li class="failures"><a href="javascript:void(0);">failures:</a> <em>0</em></li>' ++ '<li class="duration">duration: <em>0</em>s</li>' ++ '</ul>';/*** Initialize a new `HTML` reporter.@@ -45,7 +45,7 @@ var statsTemplate = '<ul id="mocha-stats">'* @api public* @param {Runner} runner*/-function HTML(runner) {+function HTML (runner) {Base.call(this, runner);var self = this;@@ -80,7 +80,7 @@ function HTML(runner) {}// pass toggle- on(passesLink, 'click', function(evt) {+ on(passesLink, 'click', function (evt) {evt.preventDefault();unhide();var name = (/pass/).test(report.className) ? '' : ' pass';@@ -91,7 +91,7 @@ function HTML(runner) {});// failure toggle- on(failuresLink, 'click', function(evt) {+ on(failuresLink, 'click', function (evt) {evt.preventDefault();unhide();var name = (/fail/).test(report.className) ? '' : ' fail';@@ -108,7 +108,7 @@ function HTML(runner) {progress.size(40);}- runner.on('suite', function(suite) {+ runner.on('suite', function (suite) {if (suite.root) {return;}@@ -123,7 +123,7 @@ function HTML(runner) {el.appendChild(stack[0]);});- runner.on('suite end', function(suite) {+ runner.on('suite end', function (suite) {if (suite.root) {updateStats();return;@@ -131,17 +131,17 @@ function HTML(runner) {stack.shift();});- 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">‣</a></h2></li>';+ var markup = '<li class="test pass %e"><h2>%e<span class="duration">%ems</span> ' ++ '<a href="%s" class="replay">‣</a></h2></li>';var el = fragment(markup, test.speed, test.title, test.duration, url);self.addCodeToggle(el, test.body);appendToStack(el);updateStats();});- runner.on('fail', function(test) {+ runner.on('fail', function (test) {var el = fragment('<li class="test fail"><h2>%e <a href="%e" class="replay">‣</a></h2></li>',test.title, self.testURL(test));var stackString; // Note: Includes leading newline@@ -181,20 +181,20 @@ function HTML(runner) {updateStats();});- runner.on('pending', function(test) {+ runner.on('pending', function (test) {var el = fragment('<li class="test pass pending"><h2>%e</h2></li>', test.title);appendToStack(el);updateStats();});- function appendToStack(el) {+ function appendToStack (el) {// Don't call .appendChild if #mocha-report was already .shift()'ed off the stack.if (stack[0]) {stack[0].appendChild(el);}}- function updateStats() {+ function updateStats () {// TODO: add to statsvar percent = stats.tests / runner.total * 100 | 0;if (progress) {@@ -215,7 +215,7 @@ function HTML(runner) {* @param {string} s* @return {string} A new URL.*/-function makeUrl(s) {+function makeUrl (s) {var search = window.location.search;// Remove previous grep query parameter if present@@ -231,7 +231,7 @@ function makeUrl(s) {** @param {Object} [suite]*/-HTML.prototype.suiteURL = function(suite) {+HTML.prototype.suiteURL = function (suite) {return makeUrl(suite.fullTitle());};@@ -240,7 +240,7 @@ HTML.prototype.suiteURL = function(suite) {** @param {Object} [test]*/-HTML.prototype.testURL = function(test) {+HTML.prototype.testURL = function (test) {return makeUrl(test.fullTitle());};@@ -250,10 +250,10 @@ HTML.prototype.testURL = function(test) {* @param {HTMLLIElement} el* @param {string} contents*/-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';});@@ -267,7 +267,7 @@ HTML.prototype.addCodeToggle = function(el, contents) {** @param {string} msg*/-function error(msg) {+function error (msg) {document.body.appendChild(fragment('<div id="mocha-error">%s</div>', msg));}@@ -276,12 +276,12 @@ function error(msg) {** @param {string} html*/-function fragment(html) {+function fragment (html) {var args = arguments;var div = document.createElement('div');var i = 1;- 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++]);@@ -298,7 +298,7 @@ function fragment(html) {** @param {text} classname*/-function hideSuitesWithout(classname) {+function hideSuitesWithout (classname) {var suites = document.getElementsByClassName('suite');for (var i = 0; i < suites.length; i++) {var els = suites[i].getElementsByClassName(classname);@@ -311,7 +311,7 @@ function hideSuitesWithout(classname) {/*** Unhide .hidden suites.*/-function unhide() {+function unhide () {var els = document.getElementsByClassName('suite hidden');for (var i = 0; i < els.length; ++i) {els[i].className = els[i].className.replace('suite hidden', 'suite');@@ -324,7 +324,7 @@ function unhide() {* @param {HTMLElement} el* @param {string} contents*/-function text(el, contents) {+function text (el, contents) {if (el.textContent) {el.textContent = contents;} else {@@ -335,7 +335,7 @@ function text(el, contents) {/*** Listen on `event` with callback `fn`.*/-function on(el, event, fn) {+function on (el, event, fn) {if (el.addEventListener) {el.addEventListener(event, fn, false);} else {diff --git a/lib/reporters/json-stream.js b/lib/reporters/json-stream.jsindex f07f8657..a528abf8 100644--- a/lib/reporters/json-stream.js+++ b/lib/reporters/json-stream.js@@ -17,28 +17,28 @@ exports = module.exports = List;* @api public* @param {Runner} runner*/-function List(runner) {+function List (runner) {Base.call(this, runner);var self = this;var total = runner.total;- runner.on('start', function() {+ 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);test.err = err.message;test.stack = err.stack || null;console.log(JSON.stringify(['fail', test]));});- runner.on('end', function() {+ runner.on('end', function () {process.stdout.write(JSON.stringify(['end', self.stats]));});}@@ -51,7 +51,7 @@ function List(runner) {* @param {Object} test* @return {Object}*/-function clean(test) {+function clean (test) {return {title: test.title,fullTitle: test.fullTitle(),diff --git a/lib/reporters/json.js b/lib/reporters/json.jsindex cd9ec286..42bcd96d 100644--- a/lib/reporters/json.js+++ b/lib/reporters/json.js@@ -16,7 +16,7 @@ exports = module.exports = JSONReporter;* @api public* @param {Runner} runner*/-function JSONReporter(runner) {+function JSONReporter (runner) {Base.call(this, runner);var self = this;@@ -25,23 +25,23 @@ function JSONReporter(runner) {var failures = [];var passes = [];- 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.on('end', function() {+ runner.on('end', function () {var obj = {stats: self.stats,tests: tests.map(clean),@@ -64,7 +64,7 @@ function JSONReporter(runner) {* @param {Object} test* @return {Object}*/-function clean(test) {+function clean (test) {return {title: test.title,fullTitle: test.fullTitle(),@@ -81,9 +81,9 @@ function clean(test) {* @param {Error} err* @return {Object}*/-function errorJSON(err) {+function errorJSON (err) {var res = {};- Object.getOwnPropertyNames(err).forEach(function(key) {+ Object.getOwnPropertyNames(err).forEach(function (key) {res[key] = err[key];}, err);return res;diff --git a/lib/reporters/landing.js b/lib/reporters/landing.jsindex b66b2000..c5da809d 100644--- a/lib/reporters/landing.js+++ b/lib/reporters/landing.js@@ -37,28 +37,28 @@ Base.colors.runway = 90;* @api public* @param {Runner} runner*/-function Landing(runner) {+function Landing (runner) {Base.call(this, runner);var self = this;- var width = Base.window.width * .75 | 0;+ var width = Base.window.width * 0.75 | 0;var total = runner.total;var stream = process.stdout;var plane = color('plane', '✈');var crashed = -1;var n = 0;- function runway() {+ function runway () {var buf = Array(width).join('-');return ' ' + color('runway', buf);}- runner.on('start', function() {+ runner.on('start', function () {stream.write('\n\n\n ');cursor.hide();});- runner.on('test end', function(test) {+ runner.on('test end', function (test) {// check if the plane crashedvar col = crashed === -1 ? width * ++n / total | 0 : crashed;@@ -79,7 +79,7 @@ function Landing(runner) {stream.write('\u001b[0m');});- runner.on('end', function() {+ runner.on('end', function () {cursor.show();console.log();self.epilogue();diff --git a/lib/reporters/list.js b/lib/reporters/list.jsindex 0e5f910d..e154b069 100644--- a/lib/reporters/list.js+++ b/lib/reporters/list.js@@ -19,35 +19,35 @@ exports = module.exports = List;* @api public* @param {Runner} runner*/-function List(runner) {+function List (runner) {Base.call(this, runner);var self = this;var n = 0;- 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.dot)- + color('pass', ' %s: ')- + color(test.speed, '%dms');+ runner.on('pass', function (test) {+ var fmt = color('checkmark', ' ' + Base.symbols.dot) ++ color('pass', ' %s: ') ++ color(test.speed, '%dms');cursor.CR();console.log(fmt, test.fullTitle(), test.duration);});- runner.on('fail', function(test) {+ runner.on('fail', function (test) {cursor.CR();console.log(color('fail', ' %d) %s'), ++n, test.fullTitle());});diff --git a/lib/reporters/markdown.js b/lib/reporters/markdown.jsindex 680c55d7..01c76a7e 100644--- a/lib/reporters/markdown.js+++ b/lib/reporters/markdown.js@@ -23,29 +23,29 @@ exports = module.exports = Markdown;* @api public* @param {Runner} runner*/-function Markdown(runner) {+function Markdown (runner) {Base.call(this, runner);var level = 0;var buf = '';- 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) {+ suite.suites.forEach(function (suite) {mapTOC(suite, obj);});return ret;}- function stringifyTOC(obj, level) {+ function stringifyTOC (obj, level) {++level;var buf = '';var link;@@ -63,25 +63,25 @@ function Markdown(runner) {return buf;}- function generateTOC(suite) {+ function generateTOC (suite) {var obj = mapTOC(suite, {});return stringifyTOC(obj, 0);}generateTOC(runner.suite);- runner.on('suite', function(suite) {+ runner.on('suite', function (suite) {++level;var slug = utils.slug(suite.fullTitle());buf += '<a name="' + slug + '"></a>' + '\n';buf += title(suite.title) + '\n';});- 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);buf += test.title + '.\n';buf += '\n```js\n';@@ -89,7 +89,7 @@ function Markdown(runner) {buf += '```\n\n';});- runner.on('end', function() {+ runner.on('end', function () {process.stdout.write('# TOC\n');process.stdout.write(generateTOC(runner.suite));process.stdout.write(buf);diff --git a/lib/reporters/min.js b/lib/reporters/min.jsindex 2b48212c..f0e690ab 100644--- a/lib/reporters/min.js+++ b/lib/reporters/min.js@@ -17,10 +17,10 @@ exports = module.exports = Min;* @api public* @param {Runner} runner*/-function Min(runner) {+function Min (runner) {Base.call(this, runner);- runner.on('start', function() {+ runner.on('start', function () {// clear screenprocess.stdout.write('\u001b[2J');// set cursor positiondiff --git a/lib/reporters/nyan.js b/lib/reporters/nyan.jsindex ba1b0509..a8c0b852 100644--- a/lib/reporters/nyan.js+++ b/lib/reporters/nyan.js@@ -18,11 +18,11 @@ exports = module.exports = NyanCat;* @api public*/-function NyanCat(runner) {+function NyanCat (runner) {Base.call(this, runner);var self = this;- var width = Base.window.width * .75 | 0;+ var width = Base.window.width * 0.75 | 0;var nyanCatWidth = this.nyanCatWidth = 11;this.colorIndex = 0;@@ -33,24 +33,24 @@ function NyanCat(runner) {this.trajectories = [[], [], [], []];this.trajectoryWidthMax = (width - nyanCatWidth);- runner.on('start', function() {+ runner.on('start', function () {Base.cursor.hide();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.on('end', function() {+ runner.on('end', function () {Base.cursor.show();for (var i = 0; i < self.numberOfLines; i++) {write('\n');@@ -70,7 +70,7 @@ inherits(NyanCat, Base);* @api private*/-NyanCat.prototype.draw = function() {+NyanCat.prototype.draw = function () {this.appendRainbow();this.drawScoreboard();this.drawRainbow();@@ -85,10 +85,10 @@ NyanCat.prototype.draw = function() {* @api private*/-NyanCat.prototype.drawScoreboard = function() {+NyanCat.prototype.drawScoreboard = function () {var stats = this.stats;- function draw(type, n) {+ function draw (type, n) {write(' ');write(Base.color(type, n));write('\n');@@ -108,7 +108,7 @@ NyanCat.prototype.drawScoreboard = function() {* @api private*/-NyanCat.prototype.appendRainbow = function() {+NyanCat.prototype.appendRainbow = function () {var segment = this.tick ? '_' : '-';var rainbowified = this.rainbowify(segment);@@ -127,10 +127,10 @@ NyanCat.prototype.appendRainbow = function() {* @api private*/-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');write(line.join(''));write('\n');@@ -144,7 +144,7 @@ NyanCat.prototype.drawRainbow = function() {** @api private*/-NyanCat.prototype.drawNyanCat = function() {+NyanCat.prototype.drawNyanCat = function () {var self = this;var startWidth = this.scoreboardWidth + this.trajectories[0].length;var dist = '\u001b[' + startWidth + 'C';@@ -180,7 +180,7 @@ NyanCat.prototype.drawNyanCat = function() {* @return {string}*/-NyanCat.prototype.face = function() {+NyanCat.prototype.face = function () {var stats = this.stats;if (stats.failures) {return '( x .x)';@@ -199,7 +199,7 @@ NyanCat.prototype.face = function() {* @param {number} n*/-NyanCat.prototype.cursorUp = function(n) {+NyanCat.prototype.cursorUp = function (n) {write('\u001b[' + n + 'A');};@@ -210,7 +210,7 @@ NyanCat.prototype.cursorUp = function(n) {* @param {number} n*/-NyanCat.prototype.cursorDown = function(n) {+NyanCat.prototype.cursorDown = function (n) {write('\u001b[' + n + 'B');};@@ -220,7 +220,7 @@ NyanCat.prototype.cursorDown = function(n) {* @api private* @return {Array}*/-NyanCat.prototype.generateColors = function() {+NyanCat.prototype.generateColors = function () {var colors = [];for (var i = 0; i < (6 * 7); i++) {@@ -242,7 +242,7 @@ NyanCat.prototype.generateColors = function() {* @param {string} str* @return {string}*/-NyanCat.prototype.rainbowify = function(str) {+NyanCat.prototype.rainbowify = function (str) {if (!Base.useColors) {return str;}@@ -256,6 +256,6 @@ NyanCat.prototype.rainbowify = function(str) {** @param {string} string A message to write to stdout.*/-function write(string) {+function write (string) {process.stdout.write(string);}diff --git a/lib/reporters/progress.js b/lib/reporters/progress.jsindex 5349ca89..d4c2144b 100644--- a/lib/reporters/progress.js+++ b/lib/reporters/progress.js@@ -26,11 +26,11 @@ Base.colors.progress = 90;* @param {Runner} runner* @param {Object} options*/-function Progress(runner, options) {+function Progress (runner, options) {Base.call(this, runner);var self = this;- var width = Base.window.width * .50 | 0;+ var width = Base.window.width * 0.50 | 0;var total = runner.total;var complete = 0;var lastN = -1;@@ -44,13 +44,13 @@ function Progress(runner, options) {options.verbose = false;// tests started- runner.on('start', function() {+ runner.on('start', function () {console.log();cursor.hide();});// tests complete- runner.on('test end', function() {+ runner.on('test end', function () {complete++;var percent = complete / total;@@ -76,7 +76,7 @@ function Progress(runner, options) {// tests are complete, output some stats// and the failures if any- runner.on('end', function() {+ runner.on('end', function () {cursor.show();console.log();self.epilogue();diff --git a/lib/reporters/spec.js b/lib/reporters/spec.jsindex 28993a8f..ce5894d2 100644--- a/lib/reporters/spec.js+++ b/lib/reporters/spec.js@@ -18,55 +18,55 @@ exports = module.exports = Spec;* @api public* @param {Runner} runner*/-function Spec(runner) {+function Spec (runner) {Base.call(this, runner);var self = this;var indents = 0;var n = 0;- 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;console.log(color('suite', '%s%s'), indent(), suite.title);});- runner.on('suite end', function() {+ runner.on('suite end', function () {--indents;if (indents === 1) {console.log();}});- runner.on('pending', function(test) {+ runner.on('pending', function (test) {var fmt = indent() + color('pending', ' - %s');console.log(fmt, test.title);});- runner.on('pass', function(test) {+ runner.on('pass', function (test) {var fmt;if (test.speed === 'fast') {- fmt = indent()- + color('checkmark', ' ' + Base.symbols.ok)- + color('pass', ' %s');+ fmt = indent() ++ color('checkmark', ' ' + Base.symbols.ok) ++ color('pass', ' %s');console.log(fmt, test.title);} else {- fmt = indent()- + color('checkmark', ' ' + Base.symbols.ok)- + color('pass', ' %s')- + color(test.speed, ' (%dms)');+ fmt = indent() ++ color('checkmark', ' ' + Base.symbols.ok) ++ color('pass', ' %s') ++ color(test.speed, ' (%dms)');console.log(fmt, test.title, test.duration);}});- runner.on('fail', function(test) {+ runner.on('fail', function (test) {console.log(indent() + color('fail', ' %d) %s'), ++n, test.title);});diff --git a/lib/reporters/tap.js b/lib/reporters/tap.jsindex d9b1b953..13c82c1d 100644--- a/lib/reporters/tap.js+++ b/lib/reporters/tap.js@@ -16,32 +16,32 @@ exports = module.exports = TAP;* @api public* @param {Runner} runner*/-function TAP(runner) {+function TAP (runner) {Base.call(this, runner);var n = 1;var passes = 0;var failures = 0;- runner.on('start', function() {+ runner.on('start', function () {var total = runner.grepTotal(runner.suite);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++;console.log('ok %d %s', n, title(test));});- runner.on('fail', function(test, err) {+ runner.on('fail', function (test, err) {failures++;console.log('not ok %d %s', n, title(test));if (err.stack) {@@ -49,7 +49,7 @@ function TAP(runner) {}});- runner.on('end', function() {+ runner.on('end', function () {console.log('# tests ' + (passes + failures));console.log('# pass ' + passes);console.log('# fail ' + failures);@@ -63,6 +63,6 @@ function TAP(runner) {* @param {Object} test* @return {String}*/-function title(test) {+function title (test) {return test.fullTitle().replace(/#/g, '');}diff --git a/lib/reporters/xunit.js b/lib/reporters/xunit.jsindex 1cfd8f4f..fb3b8469 100644--- a/lib/reporters/xunit.js+++ b/lib/reporters/xunit.js@@ -34,7 +34,7 @@ exports = module.exports = XUnit;* @api public* @param {Runner} runner*/-function XUnit(runner, options) {+function XUnit (runner, options) {Base.call(this, runner);var stats = this.stats;@@ -49,19 +49,19 @@ function XUnit(runner, options) {self.fileStream = fs.createWriteStream(options.reporterOptions.output);}- 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.on('end', function() {+ runner.on('end', function () {self.write(tag('testsuite', {name: 'Mocha Tests',tests: stats.tests,@@ -72,7 +72,7 @@ function XUnit(runner, options) {time: (stats.duration / 1000) || 0}, false));- tests.forEach(function(t) {+ tests.forEach(function (t) {self.test(t);});@@ -91,9 +91,9 @@ inherits(XUnit, Base);* @param failures* @param {Function} fn*/-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);});} else {@@ -106,7 +106,7 @@ XUnit.prototype.done = function(failures, fn) {** @param {string} line*/-XUnit.prototype.write = function(line) {+XUnit.prototype.write = function (line) {if (this.fileStream) {this.fileStream.write(line + '\n');} else if (typeof process === 'object' && process.stdout) {@@ -121,7 +121,7 @@ XUnit.prototype.write = function(line) {** @param {Test} test*/-XUnit.prototype.test = function(test) {+XUnit.prototype.test = function (test) {var attrs = {classname: test.parent.fullTitle(),name: test.title,@@ -147,7 +147,7 @@ XUnit.prototype.test = function(test) {* @param content* @return {string}*/-function tag(name, attrs, close, content) {+function tag (name, attrs, close, content) {var end = close ? '/>' : '>';var pairs = [];var tag;diff --git a/lib/runnable.js b/lib/runnable.jsindex cc138f25..bee4ef31 100644--- a/lib/runnable.js+++ b/lib/runnable.js@@ -43,7 +43,7 @@ module.exports = Runnable;* @param {string} title* @param {Function} fn*/-function Runnable(title, fn) {+function Runnable (title, fn) {this.title = title;this.fn = fn;this.body = (fn || '').toString();@@ -73,7 +73,7 @@ Runnable.prototype = create(EventEmitter.prototype, {* @param {number|string} ms* @return {Runnable|number} ms or Runnable instance.*/-Runnable.prototype.timeout = function(ms) {+Runnable.prototype.timeout = function (ms) {if (!arguments.length) {return this._timeout;}@@ -99,7 +99,7 @@ Runnable.prototype.timeout = function(ms) {* @param {number|string} ms* @return {Runnable|number} ms or Runnable instance.*/-Runnable.prototype.slow = function(ms) {+Runnable.prototype.slow = function (ms) {if (typeof ms === 'undefined') {return this._slow;}@@ -118,7 +118,7 @@ Runnable.prototype.slow = function(ms) {* @param {boolean} enabled* @return {Runnable|boolean} enabled or Runnable instance.*/-Runnable.prototype.enableTimeouts = function(enabled) {+Runnable.prototype.enableTimeouts = function (enabled) {if (!arguments.length) {return this._enableTimeouts;}@@ -132,7 +132,7 @@ Runnable.prototype.enableTimeouts = function(enabled) {** @api public*/-Runnable.prototype.skip = function() {+Runnable.prototype.skip = function () {throw new Pending('sync skip');};@@ -141,7 +141,7 @@ Runnable.prototype.skip = function() {** @api private*/-Runnable.prototype.isPending = function() {+Runnable.prototype.isPending = function () {return this.pending || (this.parent && this.parent.isPending());};@@ -150,7 +150,7 @@ Runnable.prototype.isPending = function() {** @api private*/-Runnable.prototype.retries = function(n) {+Runnable.prototype.retries = function (n) {if (!arguments.length) {return this._retries;}@@ -162,7 +162,7 @@ Runnable.prototype.retries = function(n) {** @api private*/-Runnable.prototype.currentRetry = function(n) {+Runnable.prototype.currentRetry = function (n) {if (!arguments.length) {return this._currentRetry;}@@ -176,7 +176,7 @@ Runnable.prototype.currentRetry = function(n) {* @api public* @return {string}*/-Runnable.prototype.fullTitle = function() {+Runnable.prototype.fullTitle = function () {return this.parent.fullTitle() + ' ' + this.title;};@@ -185,7 +185,7 @@ Runnable.prototype.fullTitle = function() {** @api private*/-Runnable.prototype.clearTimeout = function() {+Runnable.prototype.clearTimeout = function () {clearTimeout(this.timer);};@@ -195,8 +195,8 @@ Runnable.prototype.clearTimeout = function() {* @api private* @return {string}*/-Runnable.prototype.inspect = function() {- return JSON.stringify(this, function(key, val) {+Runnable.prototype.inspect = function () {+ return JSON.stringify(this, function (key, val) {if (key[0] === '_') {return;}@@ -215,7 +215,7 @@ Runnable.prototype.inspect = function() {** @api private*/-Runnable.prototype.resetTimeout = function() {+Runnable.prototype.resetTimeout = function () {var self = this;var ms = this.timeout() || 1e9;@@ -223,7 +223,7 @@ Runnable.prototype.resetTimeout = function() {return;}this.clearTimeout();- this.timer = setTimeout(function() {+ this.timer = setTimeout(function () {if (!self._enableTimeouts) {return;}@@ -238,7 +238,7 @@ Runnable.prototype.resetTimeout = function() {* @api private* @param {string[]} globals*/-Runnable.prototype.globals = function(globals) {+Runnable.prototype.globals = function (globals) {if (!arguments.length) {return this._allowedGlobals;}@@ -251,7 +251,7 @@ Runnable.prototype.globals = function(globals) {* @param {Function} fn* @api private*/-Runnable.prototype.run = function(fn) {+Runnable.prototype.run = function (fn) {var self = this;var start = new Date();var ctx = this.ctx;@@ -264,7 +264,7 @@ Runnable.prototype.run = function(fn) {}// called multiple times- function multiple(err) {+ function multiple (err) {if (emitted) {return;}@@ -273,7 +273,7 @@ Runnable.prototype.run = function(fn) {}// finished- function done(err) {+ function done (err) {var ms = self.timeout();if (self.timedOut) {return;@@ -299,7 +299,7 @@ Runnable.prototype.run = function(fn) {this.resetTimeout();// allows skip() to be used in an explicit async context- this.skip = function asyncSkip() {+ this.skip = function asyncSkip () {done(new Pending('async skip call'));// halt execution. the Runnable will be marked pending// by the previous call, and the uncaught handler will ignore@@ -337,18 +337,18 @@ Runnable.prototype.run = function(fn) {done(utils.getError(err));}- function callFn(fn) {+ function callFn (fn) {var result = fn.call(ctx);if (result && typeof result.then === 'function') {self.resetTimeout();result- .then(function() {+ .then(function () {done();// Return null so libraries like bluebird do not warn about// subsequently constructed Promises.return null;},- function(reason) {+ function (reason) {done(reason || new Error('Promise rejected with no or falsy reason'));});} else {@@ -360,15 +360,15 @@ Runnable.prototype.run = function(fn) {}}- 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]') {return done(err);}if (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)));}return done(new Error('done() invoked with non-Error: ' + err));}diff --git a/lib/runner.js b/lib/runner.jsindex dc03ec45..3b071a4e 100644--- a/lib/runner.js+++ b/lib/runner.js@@ -61,7 +61,7 @@ module.exports = Runner;* @param {boolean} [delay] Whether or not to delay execution of root suite* until ready.*/-function Runner(suite, delay) {+function Runner (suite, delay) {var self = this;this._globals = [];this._abort = false;@@ -70,10 +70,10 @@ function Runner(suite, delay) {this.started = false;this.total = suite.total();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);});this._defaultGrep = /.*/;@@ -106,7 +106,7 @@ inherits(Runner, EventEmitter);* @param {boolean} invert* @return {Runner} Runner instance.*/-Runner.prototype.grep = function(re, invert) {+Runner.prototype.grep = function (re, invert) {debug('grep %s', re);this._grep = re;this._invert = invert;@@ -124,11 +124,11 @@ Runner.prototype.grep = function(re, invert) {* @param {Suite} suite* @return {number}*/-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());if (self._invert) {match = !match;@@ -147,7 +147,7 @@ Runner.prototype.grepTotal = function(suite) {* @return {Array}* @api private*/-Runner.prototype.globalProps = function() {+Runner.prototype.globalProps = function () {var props = keys(global);// non-enumerables@@ -170,7 +170,7 @@ Runner.prototype.globalProps = function() {* @param {Array} arr* @return {Runner} Runner instance.*/-Runner.prototype.globals = function(arr) {+Runner.prototype.globals = function (arr) {if (!arguments.length) {return this._globals;}@@ -184,7 +184,7 @@ Runner.prototype.globals = function(arr) {** @api private*/-Runner.prototype.checkGlobals = function(test) {+Runner.prototype.checkGlobals = function (test) {if (this.ignoreLeaks) {return;}@@ -219,7 +219,7 @@ Runner.prototype.checkGlobals = function(test) {* @param {Test} test* @param {Error} err*/-Runner.prototype.fail = function(test, err) {+Runner.prototype.fail = function (test, err) {if (test.isPending()) {return;}@@ -258,7 +258,7 @@ Runner.prototype.fail = function(test, err) {* @param {Hook} hook* @param {Error} err*/-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 + '"';@@ -278,12 +278,12 @@ Runner.prototype.failHook = function(hook, err) {* @param {Function} fn*/-Runner.prototype.hook = function(name, fn) {+Runner.prototype.hook = function (name, fn) {var suite = this.suite;var hooks = suite['_' + name];var self = this;- function next(i) {+ function next (i) {var hook = hooks[i];if (!hook) {return fn();@@ -295,12 +295,12 @@ Runner.prototype.hook = function(name, fn) {self.emit('hook', hook);if (!hook.listeners('error').length) {- hook.on('error', function(err) {+ hook.on('error', function (err) {self.failHook(hook, err);});}- hook.run(function(err) {+ hook.run(function (err) {var testError = hook.error();if (testError) {self.fail(self.test, testError);@@ -310,7 +310,7 @@ Runner.prototype.hook = function(name, fn) {if (name === 'beforeEach' || name === 'afterEach') {self.test.pending = true;} else {- utils.forEach(suite.tests, function(test) {+ utils.forEach(suite.tests, function (test) {test.pending = true;});// a pending hook won't be executed twice.@@ -329,7 +329,7 @@ Runner.prototype.hook = function(name, fn) {});}- Runner.immediately(function() {+ Runner.immediately(function () {next(0);});};@@ -343,11 +343,11 @@ Runner.prototype.hook = function(name, fn) {* @param {Array} suites* @param {Function} fn*/-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;if (!suite) {@@ -355,7 +355,7 @@ Runner.prototype.hooks = function(name, suites, fn) {return fn();}- self.hook(name, function(err) {+ self.hook(name, function (err) {if (err) {var errSuite = self.suite;self.suite = orig;@@ -376,7 +376,7 @@ Runner.prototype.hooks = function(name, suites, fn) {* @param {Function} fn* @api private*/-Runner.prototype.hookUp = function(name, fn) {+Runner.prototype.hookUp = function (name, fn) {var suites = [this.suite].concat(this.parents()).reverse();this.hooks(name, suites, fn);};@@ -388,7 +388,7 @@ Runner.prototype.hookUp = function(name, fn) {* @param {Function} fn* @api private*/-Runner.prototype.hookDown = function(name, fn) {+Runner.prototype.hookDown = function (name, fn) {var suites = [this.suite].concat(this.parents());this.hooks(name, suites, fn);};@@ -400,7 +400,7 @@ Runner.prototype.hookDown = function(name, fn) {* @return {Array}* @api private*/-Runner.prototype.parents = function() {+Runner.prototype.parents = function () {var suite = this.suite;var suites = [];while (suite.parent) {@@ -416,7 +416,7 @@ Runner.prototype.parents = function() {* @param {Function} fn* @api private*/-Runner.prototype.runTest = function(fn) {+Runner.prototype.runTest = function (fn) {var self = this;var test = this.test;@@ -432,7 +432,7 @@ Runner.prototype.runTest = function(fn) {return test.run(fn);}try {- test.on('error', function(err) {+ test.on('error', function (err) {self.fail(test, err);});test.run(fn);@@ -448,12 +448,12 @@ Runner.prototype.runTest = function(fn) {* @param {Suite} suite* @param {Function} fn*/-Runner.prototype.runTests = function(suite, fn) {+Runner.prototype.runTests = function (suite, fn) {var self = this;var tests = suite.tests.slice();var test;- function hookErr(_, errSuite, after) {+ function hookErr (_, errSuite, after) {// before/after Each hook for errSuite failed:var orig = self.suite;@@ -463,7 +463,7 @@ Runner.prototype.runTests = function(suite, fn) {if (self.suite) {// call hookUp afterEach- self.hookUp('afterEach', function(err2, errSuite2) {+ self.hookUp('afterEach', function (err2, errSuite2) {self.suite = orig;// some hooks may fail even nowif (err2) {@@ -479,7 +479,7 @@ Runner.prototype.runTests = function(suite, fn) {}}- function next(err, errSuite) {+ function next (err, errSuite) {// if we bail after first errif (self.failures && suite._bail) {return fn();@@ -531,7 +531,7 @@ Runner.prototype.runTests = function(suite, fn) {// execute test and hook(s)self.emit('test', self.test = test);- self.hookDown('beforeEach', function(err, errSuite) {+ self.hookDown('beforeEach', function (err, errSuite) {if (test.isPending()) {self.emit('pending', test);self.emit('test end', test);@@ -541,7 +541,7 @@ Runner.prototype.runTests = function(suite, fn) {return hookErr(err, errSuite, false);}self.currentRunnable = self.test;- self.runTest(function(err) {+ self.runTest(function (err) {test = self.test;if (err) {var retry = test.currentRetry();@@ -588,7 +588,7 @@ Runner.prototype.runTests = function(suite, fn) {* @param {Suite} suite* @param {Function} fn*/-Runner.prototype.runSuite = function(suite, fn) {+Runner.prototype.runSuite = function (suite, fn) {var i = 0;var self = this;var total = this.grepTotal(suite);@@ -602,7 +602,7 @@ Runner.prototype.runSuite = function(suite, fn) {this.emit('suite', this.suite = suite);- function next(errSuite) {+ function next (errSuite) {if (errSuite) {// current suite failed on a hook from errSuiteif (errSuite === suite) {@@ -628,7 +628,7 @@ Runner.prototype.runSuite = function(suite, fn) {// huge recursive loop and thus a maximum call stack error.// See comment in `this.runTests()` for more information.if (self._grep !== self._defaultGrep) {- Runner.immediately(function() {+ Runner.immediately(function () {self.runSuite(curr, next);});} else {@@ -636,7 +636,7 @@ Runner.prototype.runSuite = function(suite, fn) {}}- function done(errSuite) {+ function done (errSuite) {self.suite = suite;self.nextSuite = next;@@ -650,7 +650,7 @@ Runner.prototype.runSuite = function(suite, fn) {// remove reference to testdelete self.test;- self.hook('afterAll', function() {+ self.hook('afterAll', function () {self.emit('suite end', suite);fn(errSuite);});@@ -659,7 +659,7 @@ Runner.prototype.runSuite = function(suite, fn) {this.nextSuite = next;- this.hook('beforeAll', function(err) {+ this.hook('beforeAll', function (err) {if (err) {return done();}@@ -673,9 +673,9 @@ Runner.prototype.runSuite = function(suite, fn) {* @param {Error} err* @api private*/-Runner.prototype.uncaught = function(err) {+Runner.prototype.uncaught = function (err) {if (err) {- debug('uncaught exception %s', err !== function() {+ debug('uncaught exception %s', err !== function () {return this;}.call(err) ? err : (err.message || err));} else {@@ -746,8 +746,8 @@ Runner.prototype.uncaught = function(err) {** @param {Suite} suite*/-function cleanSuiteReferences(suite) {- function cleanArrReferences(arr) {+function cleanSuiteReferences (suite) {+ function cleanArrReferences (arr) {for (var i = 0; i < arr.length; i++) {delete arr[i].fn;}@@ -784,7 +784,7 @@ function cleanSuiteReferences(suite) {* @param {Function} fn* @return {Runner} Runner instance.*/-Runner.prototype.run = function(fn) {+Runner.prototype.run = function (fn) {var self = this;var rootSuite = this.suite;@@ -793,16 +793,16 @@ Runner.prototype.run = function(fn) {filterOnly(rootSuite);}- fn = fn || function() {};+ fn = fn || function () {};- function uncaught(err) {+ function uncaught (err) {self.uncaught(err);}- function start() {+ function start () {self.started = true;self.emit('start');- self.runSuite(rootSuite, function() {+ self.runSuite(rootSuite, function () {debug('finished running');self.emit('end');});@@ -814,7 +814,7 @@ Runner.prototype.run = function(fn) {this.on('suite end', cleanSuiteReferences);// callback- this.on('end', function() {+ this.on('end', function () {debug('end');process.removeListener('uncaughtException', uncaught);fn(self.failures);@@ -841,7 +841,7 @@ Runner.prototype.run = function(fn) {* @api public* @return {Runner} Runner instance.*/-Runner.prototype.abort = function() {+Runner.prototype.abort = function () {debug('aborting');this._abort = true;@@ -855,7 +855,7 @@ Runner.prototype.abort = function() {* @returns {Boolean}* @api private*/-function filterOnly(suite) {+function filterOnly (suite) {if (suite._onlyTests.length) {// If the suite contains `only` tests, run those and ignore any nested suites.suite.tests = suite._onlyTests;@@ -863,7 +863,7 @@ function filterOnly(suite) {} else {// Otherwise, do not run any of the tests in this suite.suite.tests = [];- utils.forEach(suite._onlySuites, function(onlySuite) {+ utils.forEach(suite._onlySuites, function (onlySuite) {// If there are other `only` tests/suites nested in the current `only` suite, then filter that `only` suite.// Otherwise, all of the tests on this `only` suite should be run, so don't filter it.if (hasOnly(onlySuite)) {@@ -871,7 +871,7 @@ function filterOnly(suite) {}});// Run the `only` suites, as well as any other suites that have `only` tests/suites as descendants.- suite.suites = filter(suite.suites, function(childSuite) {+ suite.suites = filter(suite.suites, function (childSuite) {return indexOf(suite._onlySuites, childSuite) !== -1 || filterOnly(childSuite);});}@@ -886,7 +886,7 @@ function filterOnly(suite) {* @returns {Boolean}* @api private*/-function hasOnly(suite) {+function hasOnly (suite) {return suite._onlyTests.length || suite._onlySuites.length || some(suite.suites, hasOnly);}@@ -898,8 +898,8 @@ function hasOnly(suite) {* @param {Array} globals* @return {Array}*/-function filterLeaks(ok, globals) {- return filter(globals, function(key) {+function filterLeaks (ok, globals) {+ return filter(globals, function (key) {// Firefox and Chrome exposes iframes as index inside the window objectif (/^\d+/.test(key)) {return false;@@ -923,7 +923,7 @@ function filterLeaks(ok, globals) {return false;}- var matched = filter(ok, function(ok) {+ var matched = filter(ok, function (ok) {if (~ok.indexOf('*')) {return key.indexOf(ok.split('*')[0]) === 0;}@@ -939,10 +939,10 @@ function filterLeaks(ok, globals) {* @return {Array}* @api private*/-function extraGlobals() {+function extraGlobals () {if (typeof process === 'object' && typeof process.version === 'string') {var parts = process.version.split('.');- var nodeVersion = utils.reduce(parts, function(a, v) {+ var nodeVersion = utils.reduce(parts, function (a, v) {return a << 8 | v;});diff --git a/lib/suite.js b/lib/suite.jsindex bf3e4e9f..7f3c5054 100644--- a/lib/suite.js+++ b/lib/suite.js@@ -25,7 +25,7 @@ exports = module.exports = Suite;* @param {string} title* @return {Suite}*/-exports.create = function(parent, title) {+exports.create = function (parent, title) {var suite = new Suite(title, parent.ctx);suite.parent = parent;title = suite.fullTitle();@@ -40,12 +40,12 @@ exports.create = function(parent, title) {* @param {string} title* @param {Context} parentContext*/-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.');}this.title = title;- function Context() {}+ function Context () {}Context.prototype = parentContext;this.ctx = new Context();this.suites = [];@@ -77,7 +77,7 @@ inherits(Suite, EventEmitter);* @api private* @return {Suite}*/-Suite.prototype.clone = function() {+Suite.prototype.clone = function () {var suite = new Suite(this.title);debug('clone');suite.ctx = this.ctx;@@ -96,7 +96,7 @@ Suite.prototype.clone = function() {* @param {number|string} ms* @return {Suite|number} for chaining*/-Suite.prototype.timeout = function(ms) {+Suite.prototype.timeout = function (ms) {if (!arguments.length) {return this._timeout;}@@ -118,7 +118,7 @@ Suite.prototype.timeout = function(ms) {* @param {number|string} n* @return {Suite|number} for chaining*/-Suite.prototype.retries = function(n) {+Suite.prototype.retries = function (n) {if (!arguments.length) {return this._retries;}@@ -134,7 +134,7 @@ Suite.prototype.retries = function(n) {* @param {boolean} enabled* @return {Suite|boolean} self or enabled*/-Suite.prototype.enableTimeouts = function(enabled) {+Suite.prototype.enableTimeouts = function (enabled) {if (!arguments.length) {return this._enableTimeouts;}@@ -150,7 +150,7 @@ Suite.prototype.enableTimeouts = function(enabled) {* @param {number|string} ms* @return {Suite|number} for chaining*/-Suite.prototype.slow = function(ms) {+Suite.prototype.slow = function (ms) {if (!arguments.length) {return this._slow;}@@ -169,7 +169,7 @@ Suite.prototype.slow = function(ms) {* @param {boolean} bail* @return {Suite|number} for chaining*/-Suite.prototype.bail = function(bail) {+Suite.prototype.bail = function (bail) {if (!arguments.length) {return this._bail;}@@ -183,7 +183,7 @@ Suite.prototype.bail = function(bail) {** @api private*/-Suite.prototype.isPending = function() {+Suite.prototype.isPending = function () {return this.pending || (this.parent && this.parent.isPending());};@@ -195,7 +195,7 @@ Suite.prototype.isPending = function() {* @param {Function} fn* @return {Suite} for chaining*/-Suite.prototype.beforeAll = function(title, fn) {+Suite.prototype.beforeAll = function (title, fn) {if (this.isPending()) {return this;}@@ -225,7 +225,7 @@ Suite.prototype.beforeAll = function(title, fn) {* @param {Function} fn* @return {Suite} for chaining*/-Suite.prototype.afterAll = function(title, fn) {+Suite.prototype.afterAll = function (title, fn) {if (this.isPending()) {return this;}@@ -255,7 +255,7 @@ Suite.prototype.afterAll = function(title, fn) {* @param {Function} fn* @return {Suite} for chaining*/-Suite.prototype.beforeEach = function(title, fn) {+Suite.prototype.beforeEach = function (title, fn) {if (this.isPending()) {return this;}@@ -285,7 +285,7 @@ Suite.prototype.beforeEach = function(title, fn) {* @param {Function} fn* @return {Suite} for chaining*/-Suite.prototype.afterEach = function(title, fn) {+Suite.prototype.afterEach = function (title, fn) {if (this.isPending()) {return this;}@@ -314,7 +314,7 @@ Suite.prototype.afterEach = function(title, fn) {* @param {Suite} suite* @return {Suite} for chaining*/-Suite.prototype.addSuite = function(suite) {+Suite.prototype.addSuite = function (suite) {suite.parent = this;suite.timeout(this.timeout());suite.retries(this.retries());@@ -333,7 +333,7 @@ Suite.prototype.addSuite = function(suite) {* @param {Test} test* @return {Suite} for chaining*/-Suite.prototype.addTest = function(test) {+Suite.prototype.addTest = function (test) {test.parent = this;test.timeout(this.timeout());test.retries(this.retries());@@ -352,7 +352,7 @@ Suite.prototype.addTest = function(test) {* @api public* @return {string}*/-Suite.prototype.fullTitle = function() {+Suite.prototype.fullTitle = function () {if (this.parent) {var full = this.parent.fullTitle();if (full) {@@ -368,8 +368,8 @@ Suite.prototype.fullTitle = function() {* @api public* @return {number}*/-Suite.prototype.total = function() {- return utils.reduce(this.suites, function(sum, suite) {+Suite.prototype.total = function () {+ return utils.reduce(this.suites, function (sum, suite) {return sum + suite.total();}, 0) + this.tests.length;};@@ -382,9 +382,9 @@ Suite.prototype.total = function() {* @param {Function} fn* @return {Suite}*/-Suite.prototype.eachTest = function(fn) {+Suite.prototype.eachTest = function (fn) {utils.forEach(this.tests, fn);- utils.forEach(this.suites, function(suite) {+ utils.forEach(this.suites, function (suite) {suite.eachTest(fn);});return this;@@ -393,7 +393,7 @@ Suite.prototype.eachTest = function(fn) {/*** This will run the root suite if we happen to be running in delayed mode.*/-Suite.prototype.run = function run() {+Suite.prototype.run = function run () {if (this.root) {this.emit('run');}diff --git a/lib/test.js b/lib/test.jsindex 05d4ed86..b945560a 100644--- a/lib/test.js+++ b/lib/test.js@@ -19,7 +19,7 @@ module.exports = Test;* @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.');}@@ -35,7 +35,7 @@ Test.prototype = create(Runnable.prototype, {constructor: Test});-Test.prototype.clone = function() {+Test.prototype.clone = function () {var test = new Test(this.title, this.fn);test.timeout(this.timeout());test.slow(this.slow());diff --git a/lib/utils.js b/lib/utils.jsindex c7947cb0..2a77f982 100644--- a/lib/utils.js+++ b/lib/utils.js@@ -31,7 +31,7 @@ exports.inherits = require('util').inherits;* @param {string} html* @return {string}*/-exports.escape = function(html) {+exports.escape = function (html) {return String(html).replace(/&/g, '&').replace(/"/g, '"')@@ -47,7 +47,7 @@ exports.escape = function(html) {* @param {Function} fn* @param {Object} scope*/-exports.forEach = function(arr, fn, scope) {+exports.forEach = function (arr, fn, scope) {for (var i = 0, l = arr.length; i < l; i++) {fn.call(scope, arr[i], i);}@@ -60,7 +60,7 @@ exports.forEach = function(arr, fn, scope) {* @param {Object} obj* @return {boolean}*/-exports.isString = function(obj) {+exports.isString = function (obj) {return typeof obj === 'string';};@@ -73,7 +73,7 @@ exports.isString = function(obj) {* @param {Object} scope* @return {Array}*/-exports.map = function(arr, fn, scope) {+exports.map = function (arr, fn, scope) {var result = [];for (var i = 0, l = arr.length; i < l; i++) {result.push(fn.call(scope, arr[i], i, arr));@@ -90,7 +90,7 @@ exports.map = function(arr, fn, scope) {* @param {number} start* @return {number}*/-var indexOf = exports.indexOf = function(arr, obj, start) {+var indexOf = exports.indexOf = function (arr, obj, start) {for (var i = start || 0, l = arr.length; i < l; i++) {if (arr[i] === obj) {return i;@@ -108,7 +108,7 @@ var indexOf = exports.indexOf = function(arr, obj, start) {* @param {Object} val Initial value.* @return {*}*/-var reduce = exports.reduce = function(arr, fn, val) {+var reduce = exports.reduce = function (arr, fn, val) {var rval = val;for (var i = 0, l = arr.length; i < l; i++) {@@ -126,7 +126,7 @@ var reduce = exports.reduce = function(arr, fn, val) {* @param {Function} fn* @return {Array}*/-exports.filter = function(arr, fn) {+exports.filter = function (arr, fn) {var ret = [];for (var i = 0, l = arr.length; i < l; i++) {@@ -147,7 +147,7 @@ exports.filter = function(arr, fn) {* @param {Function} fn* @return {Array}*/-exports.some = function(arr, fn) {+exports.some = function (arr, fn) {for (var i = 0, l = arr.length; i < l; i++) {if (fn(arr[i])) {return true;@@ -163,7 +163,7 @@ exports.some = function(arr, fn) {* @param {Object} obj* @return {Array} keys*/-exports.keys = typeof Object.keys === 'function' ? Object.keys : function(obj) {+exports.keys = typeof Object.keys === 'function' ? Object.keys : function (obj) {var keys = [];var has = Object.prototype.hasOwnProperty; // for `window` on <=IE8@@ -184,11 +184,11 @@ exports.keys = typeof Object.keys === 'function' ? Object.keys : function(obj) {* @param {Array} files* @param {Function} fn*/-exports.watch = function(files, fn) {+exports.watch = function (files, fn) {var options = { interval: 100 };- files.forEach(function(file) {+ files.forEach(function (file) {debug('file %s', file);- watchFile(file, options, function(curr, prev) {+ watchFile(file, options, function (curr, prev) {if (prev.mtime < curr.mtime) {fn(file);}@@ -203,7 +203,7 @@ exports.watch = function(files, fn) {* @param {Object} obj* @return {Boolean}*/-var isArray = typeof Array.isArray === 'function' ? Array.isArray : function(obj) {+var isArray = typeof Array.isArray === 'function' ? Array.isArray : function (obj) {return Object.prototype.toString.call(obj) === '[object Array]';};@@ -215,7 +215,7 @@ exports.isArray = isArray;* @type {Function}*/if (typeof Buffer !== 'undefined' && Buffer.prototype) {- Buffer.prototype.toJSON = Buffer.prototype.toJSON || function() {+ Buffer.prototype.toJSON = Buffer.prototype.toJSON || function () {return Array.prototype.slice.call(this, 0);};}@@ -227,7 +227,7 @@ if (typeof Buffer !== 'undefined' && Buffer.prototype) {* @param {string} path* @return {boolean}*/-function ignored(path) {+function ignored (path) {return !~ignore.indexOf(path);}@@ -240,7 +240,7 @@ function ignored(path) {* @param {Array} [ret=[]]* @return {Array}*/-exports.files = function(dir, ext, ret) {+exports.files = function (dir, ext, ret) {ret = ret || [];ext = ext || ['js'];@@ -248,7 +248,7 @@ exports.files = function(dir, ext, ret) {readdirSync(dir).filter(ignored)- .forEach(function(path) {+ .forEach(function (path) {path = join(dir, path);if (statSync(path).isDirectory()) {exports.files(path, ext, ret);@@ -267,7 +267,7 @@ exports.files = function(dir, ext, ret) {* @param {string} str* @return {string}*/-exports.slug = function(str) {+exports.slug = function (str) {return str.toLowerCase().replace(/ +/g, '-')@@ -280,7 +280,7 @@ exports.slug = function(str) {* @param {string} str* @return {string}*/-exports.clean = function(str) {+exports.clean = function (str) {str = str.replace(/\r\n?|[\n\u2028\u2029]/g, '\n').replace(/^\uFEFF/, '')// (traditional)-> space/name parameters body (lambda)-> parameters body multi-statement/single keep body content@@ -288,7 +288,7 @@ exports.clean = function(str) {var spaces = str.match(/^\n?( *)/)[1].length;var tabs = str.match(/^\n?(\t*)/)[1].length;- var re = new RegExp('^\n?' + (tabs ? '\t' : ' ') + '{' + (tabs ? tabs : spaces) + '}', 'gm');+ var re = new RegExp('^\n?' + (tabs ? '\t' : ' ') + '{' + (tabs || spaces) + '}', 'gm');str = str.replace(re, '');@@ -302,7 +302,7 @@ exports.clean = function(str) {* @param {string} str* @return {string}*/-exports.trim = function(str) {+exports.trim = function (str) {return str.replace(/^\s+|\s+$/g, '');};@@ -313,8 +313,8 @@ exports.trim = function(str) {* @param {string} qs* @return {Object}*/-exports.parseQuery = function(qs) {- return reduce(qs.replace('?', '').split('&'), function(obj, pair) {+exports.parseQuery = function (qs) {+ return reduce(qs.replace('?', '').split('&'), function (obj, pair) {var i = pair.indexOf('=');var key = pair.slice(0, i);var val = pair.slice(++i);@@ -331,7 +331,7 @@ exports.parseQuery = function(qs) {* @param {string} js* @return {string}*/-function highlight(js) {+function highlight (js) {return js.replace(/</g, '<').replace(/>/g, '>')@@ -349,7 +349,7 @@ function highlight(js) {* @api private* @param {string} name*/-exports.highlightTags = function(name) {+exports.highlightTags = function (name) {var code = document.getElementById('mocha').getElementsByTagName(name);for (var i = 0, len = code.length; i < len; ++i) {code[i].innerHTML = highlight(code[i].innerHTML);@@ -370,7 +370,7 @@ exports.highlightTags = function(name) {* @param {string} typeHint The type of the value* @returns {string}*/-function emptyRepresentation(value, typeHint) {+function emptyRepresentation (value, typeHint) {switch (typeHint) {case 'function':return '[Function]';@@ -404,7 +404,7 @@ function emptyRepresentation(value, typeHint) {* type(global) // 'global'* type(new String('foo') // 'object'*/-var type = exports.type = function type(value) {+var type = exports.type = function type (value) {if (value === undefined) {return 'undefined';} else if (value === null) {@@ -432,7 +432,7 @@ var type = exports.type = function type(value) {* @param {*} value* @return {string}*/-exports.stringify = function(value) {+exports.stringify = function (value) {var typeHint = type(value);if (!~indexOf(['object', 'array', 'function'], typeHint)) {@@ -446,7 +446,7 @@ exports.stringify = function(value) {// IE7/IE8 has a bizarre String constructor; needs to be coerced// into an array and back to obj.if (typeHint === 'string' && typeof value === 'object') {- value = reduce(value.split(''), function(acc, char, idx) {+ value = reduce(value.split(''), function (acc, char, idx) {acc[idx] = char;return acc;}, {});@@ -474,7 +474,7 @@ exports.stringify = function(value) {* @param {number=} depth* @returns {*}*/-function jsonStringify(object, spaces, depth) {+function jsonStringify (object, spaces, depth) {if (typeof spaces === 'undefined') {// primitive typesreturn _stringify(object);@@ -486,11 +486,11 @@ function jsonStringify(object, spaces, depth) {var end = isArray(object) ? ']' : '}';var length = typeof object.length === 'number' ? object.length : exports.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)) {case 'null':case 'undefined':@@ -536,15 +536,15 @@ function jsonStringify(object, spaces, depth) {continue; // not my business}--length;- str += '\n ' + repeat(' ', space)- + (isArray(object) ? '' : '"' + i + '": ') // key- + _stringify(object[i]) // value- + (length ? ',' : ''); // comma+ str += '\n ' + repeat(' ', space) ++ (isArray(object) ? '' : '"' + i + '": ') + // key+ _stringify(object[i]) + // value+ (length ? ',' : ''); // comma}- return str+ return str +// [], {}- + (str.length !== 1 ? '\n' + repeat(' ', --space) + end : end);+ (str.length !== 1 ? '\n' + repeat(' ', --space) + end : end);}/**@@ -554,7 +554,7 @@ function jsonStringify(object, spaces, depth) {* @param {*} value The value to test.* @return {boolean} True if `value` is a buffer, otherwise false*/-exports.isBuffer = function(value) {+exports.isBuffer = function (value) {return typeof Buffer !== 'undefined' && Buffer.isBuffer(value);};@@ -577,13 +577,13 @@ exports.isBuffer = function(value) {* @param {string} [typeHint] Type hint* @return {(Object|Array|Function|string|undefined)}*/-exports.canonicalize = function canonicalize(value, stack, typeHint) {+exports.canonicalize = function canonicalize (value, stack, typeHint) {var canonicalizedObj;/* eslint-disable no-unused-vars */var prop;/* eslint-enable no-unused-vars */typeHint = typeHint || type(value);- function withStack(value, fn) {+ function withStack (value, fn) {stack.push(value);fn();stack.pop();@@ -602,8 +602,8 @@ exports.canonicalize = function canonicalize(value, stack, typeHint) {canonicalizedObj = value;break;case 'array':- withStack(value, function() {- canonicalizedObj = exports.map(value, function(item) {+ withStack(value, function () {+ canonicalizedObj = exports.map(value, function (item) {return exports.canonicalize(item, stack);});});@@ -622,8 +622,8 @@ exports.canonicalize = function canonicalize(value, stack, typeHint) {/* falls through */case 'object':canonicalizedObj = canonicalizedObj || {};- withStack(value, function() {- exports.forEach(exports.keys(value).sort(), function(key) {+ withStack(value, function () {+ exports.forEach(exports.keys(value).sort(), function (key) {canonicalizedObj[key] = exports.canonicalize(value[key], stack);});});@@ -651,7 +651,7 @@ exports.canonicalize = function canonicalize(value, stack, typeHint) {* @param {boolean} recursive Whether or not to recurse into subdirectories.* @return {string[]} An array of paths.*/-exports.lookupFiles = function lookupFiles(path, extensions, recursive) {+exports.lookupFiles = function lookupFiles (path, extensions, recursive) {var files = [];var re = new RegExp('\\.(' + extensions.join('|') + ')$');@@ -677,7 +677,7 @@ exports.lookupFiles = function lookupFiles(path, extensions, recursive) {return;}- readdirSync(path).forEach(function(file) {+ readdirSync(path).forEach(function (file) {file = join(path, file);try {var stat = statSync(file);@@ -706,7 +706,7 @@ exports.lookupFiles = function lookupFiles(path, extensions, recursive) {* @return {Error}*/-exports.undefinedError = function() {+exports.undefinedError = function () {return new Error('Caught undefined error, did you throw without specifying what?');};@@ -717,7 +717,7 @@ exports.undefinedError = function() {* @return {Error}*/-exports.getError = function(err) {+exports.getError = function (err) {return err || exports.undefinedError();};@@ -730,7 +730,7 @@ exports.getError = function(err) {* (i.e: strip Mocha and internal node functions from stack trace).* @returns {Function}*/-exports.stackTraceFilter = function() {+exports.stackTraceFilter = function () {// TODO: Replace with `process.browser`var is = typeof document === 'undefined' ? { node: true } : { browser: true };var slash = path.sep;@@ -742,26 +742,26 @@ exports.stackTraceFilter = function() {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 = reduce(stack, function(list, line) {+ stack = reduce(stack, function (list, line) {if (isMochaInternal(line)) {return list;}@@ -789,6 +789,6 @@ exports.stackTraceFilter = function() {* @param {*} value* @returns {boolean} Whether or not `value` is a Promise*/-exports.isPromise = function isPromise(value) {+exports.isPromise = function isPromise (value) {return typeof value === 'object' && typeof value.then === 'function';};diff --git a/package.json b/package.jsonindex 4ec6546e..93c07b82 100644--- a/package.json+++ b/package.json@@ -317,6 +317,10 @@"browserify": "^13.0.0","coffee-script": "^1.10.0","eslint": "^2.13.1",+ "eslint-config-semistandard": "^6.0.2",+ "eslint-config-standard": "^5.0.0",+ "eslint-plugin-promise": "^2.0.1",+ "eslint-plugin-standard": "1.3.2","expect.js": "^0.3.1","karma": "^1.1.0","karma-browserify": "^5.0.5",diff --git a/scripts/dedefine.js b/scripts/dedefine.jsindex c647c0e0..3e297586 100644--- a/scripts/dedefine.js+++ b/scripts/dedefine.js@@ -8,16 +8,16 @@var through = require('through2');var defineRx = /typeof define === ['"]function['"] && define\.amd/g;-function createStream() {- return through.obj(function(chunk, enc, next) {+function createStream () {+ return through.obj(function (chunk, enc, next) {this.push(String(chunk).replace(defineRx, 'false'));next();});}-module.exports = function(b) {- function wrap() {+module.exports = function (b) {+ function wrap () {b.pipeline.get('wrap').push(createStream());}diff --git a/test/.eslintrc b/test/.eslintrcdeleted file mode 100644index 956287d6..00000000--- a/test/.eslintrc+++ /dev/null@@ -1,5 +0,0 @@-----env:- mocha: true-globals:- expect: falsediff --git a/test/.eslintrc.js b/test/.eslintrc.jsnew file mode 100644index 00000000..5654cb80--- /dev/null+++ b/test/.eslintrc.js@@ -0,0 +1,8 @@+module.exports = {+ env: {+ mocha: true+ },+ globals: {+ expect: false+ }+};