diff --git a/.eleventy.js b/.eleventy.js index 89a80a7093..98d9faeb62 100644 --- a/.eleventy.js +++ b/.eleventy.js @@ -1,6 +1,6 @@ 'use strict'; -module.exports = function(eleventyConfig) { +module.exports = function (eleventyConfig) { eleventyConfig.addPlugin( require('@11ty/eleventy-plugin-inclusive-language'), { diff --git a/browser-entry.js b/browser-entry.js index 7f1dd99689..67517db357 100644 --- a/browser-entry.js +++ b/browser-entry.js @@ -40,12 +40,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 = uncaughtExceptionHandlers.indexOf(fn); if (i !== -1) { @@ -58,7 +58,7 @@ process.removeListener = function(e, fn) { * Implements listenerCount for 'uncaughtException'. */ -process.listenerCount = function(name) { +process.listenerCount = function (name) { if (name === 'uncaughtException') { return uncaughtExceptionHandlers.length; } @@ -69,9 +69,9 @@ process.listenerCount = function(name) { * 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.options.allowUncaught; }; @@ -79,7 +79,7 @@ process.on = function(e, fn) { } }; -process.listeners = function(e) { +process.listeners = function (e) { if (e === 'uncaughtException') { return uncaughtExceptionHandlers; } @@ -110,7 +110,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); @@ -122,8 +122,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) { - uncaughtExceptionHandlers.forEach(function(fn) { +mocha.throwError = function (err) { + uncaughtExceptionHandlers.forEach(function (fn) { fn(err); }); throw err; @@ -134,7 +134,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; @@ -144,7 +144,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}; } @@ -153,10 +153,10 @@ mocha.setup = function(opts) { } var self = this; Object.keys(opts) - .filter(function(opt) { + .filter(function (opt) { return opt !== 'delay'; }) - .forEach(function(opt) { + .forEach(function (opt) { if (Object.prototype.hasOwnProperty.call(opts, opt)) { self[opt](opts[opt]); } @@ -168,7 +168,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'); @@ -183,7 +183,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 ( diff --git a/docs/_data/supporters.js b/docs/_data/supporters.js index cbc12a84c0..4f631460f2 100755 --- a/docs/_data/supporters.js +++ b/docs/_data/supporters.js @@ -262,15 +262,19 @@ const getSupporters = async () => { if (successRate < PRODUCTION_SUCCESS_THRESHOLD) { if (process.env.NETLIFY && process.env.CONTEXT !== 'deploy-preview') { throw new Error( - `Failed to meet success threshold ${PRODUCTION_SUCCESS_THRESHOLD * - 100}% (was ${successRate * - 100}%) for a production deployment; refusing to deploy` + `Failed to meet success threshold ${ + PRODUCTION_SUCCESS_THRESHOLD * 100 + }% (was ${ + successRate * 100 + }%) for a production deployment; refusing to deploy` ); } else { console.warn( - `WARNING: Success rate of ${successRate * - 100}% fails to meet production threshold of ${PRODUCTION_SUCCESS_THRESHOLD * - 100}%; would fail a production deployment!` + `WARNING: Success rate of ${ + successRate * 100 + }% fails to meet production threshold of ${ + PRODUCTION_SUCCESS_THRESHOLD * 100 + }%; would fail a production deployment!` ); } } diff --git a/lib/browser/growl.js b/lib/browser/growl.js index 7b46b8e158..29d185de41 100644 --- a/lib/browser/growl.js +++ b/lib/browser/growl.js @@ -23,7 +23,7 @@ var isBrowser = require('../utils').isBrowser; * @see {@link Mocha#isGrowlCapable} * @return {boolean} whether browser notification support exists */ -exports.isCapable = function() { +exports.isCapable = function () { var hasNotificationSupport = 'Notification' in window; var hasPromiseSupport = typeof Promise === 'function'; return isBrowser() && hasNotificationSupport && hasPromiseSupport; @@ -39,17 +39,17 @@ exports.isCapable = function() { * @see {@link Mocha#_growl} * @param {Runner} runner - Runner instance. */ -exports.notify = function(runner) { +exports.notify = function (runner) { var promise = isPermitted(); /** * Attempt notification. */ - var sendNotification = function() { + var sendNotification = function () { // If user hasn't responded yet... "No notification for you!" (Seinfeld) Promise.race([promise, Promise.resolve(undefined)]) .then(canNotify) - .then(function() { + .then(function () { display(runner); }) .catch(notPermitted); @@ -77,7 +77,7 @@ function isPermitted() { return Promise.resolve(false); }, default: function ask() { - return Notification.requestPermission().then(function(permission) { + return Notification.requestPermission().then(function (permission) { return permission === 'granted'; }); } diff --git a/lib/browser/parse-query.js b/lib/browser/parse-query.js index dc1a884118..3a7ac1abc0 100644 --- a/lib/browser/parse-query.js +++ b/lib/browser/parse-query.js @@ -11,7 +11,7 @@ module.exports = function parseQuery(qs) { return qs .replace('?', '') .split('&') - .reduce(function(obj, pair) { + .reduce(function (obj, pair) { var i = pair.indexOf('='); var key = pair.slice(0, i); var val = pair.slice(++i); diff --git a/lib/browser/progress.js b/lib/browser/progress.js index 72ce5c57c1..30d45f6a2f 100644 --- a/lib/browser/progress.js +++ b/lib/browser/progress.js @@ -27,7 +27,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; }; @@ -39,7 +39,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; }; @@ -51,7 +51,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; }; @@ -62,7 +62,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; }; @@ -73,7 +73,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; }; @@ -84,7 +84,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/cli/run.js b/lib/cli/run.js index 4a4da6cf68..85f88bc68a 100644 --- a/lib/cli/run.js +++ b/lib/cli/run.js @@ -366,7 +366,7 @@ exports.builder = yargs => .number(types.number) .alias(aliases); -exports.handler = async function(argv) { +exports.handler = async function (argv) { debug('post-yargs config', argv); const mocha = new Mocha(argv); diff --git a/lib/cli/watch-run.js b/lib/cli/watch-run.js index 93f5059f1c..a77ed7a91a 100644 --- a/lib/cli/watch-run.js +++ b/lib/cli/watch-run.js @@ -231,10 +231,7 @@ const createWatcher = ( process.stdin.resume(); process.stdin.setEncoding('utf8'); process.stdin.on('data', data => { - const str = data - .toString() - .trim() - .toLowerCase(); + const str = data.toString().trim().toLowerCase(); if (str === 'rs') rerunner.scheduleRun(); }); diff --git a/lib/context.js b/lib/context.js index 2497ded868..388d308272 100644 --- a/lib/context.js +++ b/lib/context.js @@ -22,7 +22,7 @@ function Context() {} * @param {Runnable} runnable * @return {Context} context */ -Context.prototype.runnable = function(runnable) { +Context.prototype.runnable = function (runnable) { if (!arguments.length) { return this._runnable; } @@ -37,7 +37,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(); } @@ -52,7 +52,7 @@ Context.prototype.timeout = function(ms) { * @param {number} ms * @return {Context} self */ -Context.prototype.slow = function(ms) { +Context.prototype.slow = function (ms) { if (!arguments.length) { return this.runnable().slow(); } @@ -66,7 +66,7 @@ Context.prototype.slow = function(ms) { * @private * @throws Pending */ -Context.prototype.skip = function() { +Context.prototype.skip = function () { this.runnable().skip(); }; @@ -77,7 +77,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(); } diff --git a/lib/errors.js b/lib/errors.js index 0f0940b481..bcc7291c99 100644 --- a/lib/errors.js +++ b/lib/errors.js @@ -18,7 +18,7 @@ const emitWarning = (msg, type) => { process.emitWarning(msg, type); } else { /* istanbul ignore next */ - process.nextTick(function() { + process.nextTick(function () { console.warn(type + ': ' + msg); }); } diff --git a/lib/hook.js b/lib/hook.js index a246d053d1..862271e735 100644 --- a/lib/hook.js +++ b/lib/hook.js @@ -31,7 +31,7 @@ inherits(Hook, Runnable); /** * Resets the state for a next run. */ -Hook.prototype.reset = function() { +Hook.prototype.reset = function () { Runnable.prototype.reset.call(this); delete this._error; }; @@ -44,7 +44,7 @@ Hook.prototype.reset = function() { * @param {Error} err * @return {Error} */ -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.js index 65a6b9f6bc..bf1ffe8893 100644 --- a/lib/interfaces/bdd.js +++ b/lib/interfaces/bdd.js @@ -1,8 +1,8 @@ 'use strict'; var Test = require('../test'); -var EVENT_FILE_PRE_REQUIRE = require('../suite').constants - .EVENT_FILE_PRE_REQUIRE; +var EVENT_FILE_PRE_REQUIRE = + require('../suite').constants.EVENT_FILE_PRE_REQUIRE; /** * BDD-style interface: @@ -24,7 +24,7 @@ var EVENT_FILE_PRE_REQUIRE = require('../suite').constants module.exports = function bddInterface(suite) { var suites = [suite]; - suite.on(EVENT_FILE_PRE_REQUIRE, function(context, file, mocha) { + suite.on(EVENT_FILE_PRE_REQUIRE, function (context, file, mocha) { var common = require('./common')(suites, context, mocha); context.before = common.before; @@ -38,7 +38,7 @@ module.exports = function bddInterface(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,22 +50,22 @@ module.exports = function bddInterface(suite) { * Pending describe. */ - context.xdescribe = context.xcontext = context.describe.skip = function( - title, - fn - ) { - return common.suite.skip({ - title: title, - file: file, - fn: fn - }); - }; + context.xdescribe = + context.xcontext = + context.describe.skip = + function (title, fn) { + return common.suite.skip({ + title: title, + file: file, + fn: fn + }); + }; /** * Exclusive suite. */ - context.describe.only = function(title, fn) { + context.describe.only = function (title, fn) { return common.suite.only({ title: title, file: file, @@ -79,7 +79,7 @@ module.exports = function bddInterface(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; @@ -94,7 +94,7 @@ module.exports = function bddInterface(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)); }; @@ -102,9 +102,12 @@ module.exports = function bddInterface(suite) { * Pending test case. */ - context.xit = context.xspecify = context.it.skip = function(title) { - return context.it(title); - }; + context.xit = + context.xspecify = + context.it.skip = + function (title) { + return context.it(title); + }; }); }; diff --git a/lib/interfaces/common.js b/lib/interfaces/common.js index 20e83a16ac..ba8b5f85ed 100644 --- a/lib/interfaces/common.js +++ b/lib/interfaces/common.js @@ -19,7 +19,7 @@ var createForbiddenExclusivityError = errors.createForbiddenExclusivityError; * @param {Mocha} mocha * @return {Object} An object containing common functions. */ -module.exports = function(suites, context, mocha) { +module.exports = function (suites, context, mocha) { /** * Check if the suite should be tested. * @@ -56,7 +56,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); }, @@ -66,7 +66,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); }, @@ -76,7 +76,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); }, @@ -86,7 +86,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); }, @@ -172,7 +172,7 @@ module.exports = function(suites, context, mocha) { * @param {Function} test * @returns {*} */ - only: function(mocha, test) { + only: function (mocha, test) { if (mocha.options.forbidOnly) { throw createForbiddenExclusivityError(mocha); } @@ -185,7 +185,7 @@ module.exports = function(suites, context, mocha) { * * @param {string} title */ - skip: function(title) { + skip: function (title) { context.test(title); } } diff --git a/lib/interfaces/exports.js b/lib/interfaces/exports.js index 5b4c7bd6f4..79b762b5a9 100644 --- a/lib/interfaces/exports.js +++ b/lib/interfaces/exports.js @@ -19,7 +19,7 @@ var Test = require('../test'); * * @param {Suite} suite Root suite. */ -module.exports = function(suite) { +module.exports = function (suite) { var suites = [suite]; suite.on(Suite.constants.EVENT_FILE_REQUIRE, visit); diff --git a/lib/interfaces/qunit.js b/lib/interfaces/qunit.js index 97c3cc19f5..71cad080d9 100644 --- a/lib/interfaces/qunit.js +++ b/lib/interfaces/qunit.js @@ -1,8 +1,8 @@ 'use strict'; var Test = require('../test'); -var EVENT_FILE_PRE_REQUIRE = require('../suite').constants - .EVENT_FILE_PRE_REQUIRE; +var EVENT_FILE_PRE_REQUIRE = + require('../suite').constants.EVENT_FILE_PRE_REQUIRE; /** * QUnit-style interface: @@ -32,7 +32,7 @@ var EVENT_FILE_PRE_REQUIRE = require('../suite').constants module.exports = function qUnitInterface(suite) { var suites = [suite]; - suite.on(EVENT_FILE_PRE_REQUIRE, function(context, file, mocha) { + suite.on(EVENT_FILE_PRE_REQUIRE, function (context, file, mocha) { var common = require('./common')(suites, context, mocha); context.before = common.before; @@ -44,7 +44,7 @@ module.exports = function qUnitInterface(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 qUnitInterface(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 qUnitInterface(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 qUnitInterface(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.js index baf4d9de66..f52ae0cbc5 100644 --- a/lib/interfaces/tdd.js +++ b/lib/interfaces/tdd.js @@ -1,8 +1,8 @@ 'use strict'; var Test = require('../test'); -var EVENT_FILE_PRE_REQUIRE = require('../suite').constants - .EVENT_FILE_PRE_REQUIRE; +var EVENT_FILE_PRE_REQUIRE = + require('../suite').constants.EVENT_FILE_PRE_REQUIRE; /** * TDD-style interface: @@ -29,10 +29,10 @@ var EVENT_FILE_PRE_REQUIRE = require('../suite').constants * * @param {Suite} suite Root suite. */ -module.exports = function(suite) { +module.exports = function (suite) { var suites = [suite]; - suite.on(EVENT_FILE_PRE_REQUIRE, function(context, file, mocha) { + suite.on(EVENT_FILE_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.js index 91e6f50ac3..880b9f0d71 100644 --- a/lib/mocha.js +++ b/lib/mocha.js @@ -23,11 +23,8 @@ const { createMochaInstanceAlreadyRunningError, createUnsupportedError } = require('./errors'); -const { - EVENT_FILE_PRE_REQUIRE, - EVENT_FILE_POST_REQUIRE, - EVENT_FILE_REQUIRE -} = Suite.constants; +const {EVENT_FILE_PRE_REQUIRE, EVENT_FILE_POST_REQUIRE, EVENT_FILE_REQUIRE} = + Suite.constants; var debug = require('debug')('mocha:mocha'); exports = module.exports = Mocha; @@ -94,46 +91,46 @@ exports.Hook = require('./hook'); exports.Test = require('./test'); let currentContext; -exports.afterEach = function(...args) { +exports.afterEach = function (...args) { return (currentContext.afterEach || currentContext.teardown).apply( this, args ); }; -exports.after = function(...args) { +exports.after = function (...args) { return (currentContext.after || currentContext.suiteTeardown).apply( this, args ); }; -exports.beforeEach = function(...args) { +exports.beforeEach = function (...args) { return (currentContext.beforeEach || currentContext.setup).apply(this, args); }; -exports.before = function(...args) { +exports.before = function (...args) { return (currentContext.before || currentContext.suiteSetup).apply(this, args); }; -exports.describe = function(...args) { +exports.describe = function (...args) { return (currentContext.describe || currentContext.suite).apply(this, args); }; -exports.describe.only = function(...args) { +exports.describe.only = function (...args) { return (currentContext.describe || currentContext.suite).only.apply( this, args ); }; -exports.describe.skip = function(...args) { +exports.describe.skip = function (...args) { return (currentContext.describe || currentContext.suite).skip.apply( this, args ); }; -exports.it = function(...args) { +exports.it = function (...args) { return (currentContext.it || currentContext.test).apply(this, args); }; -exports.it.only = function(...args) { +exports.it.only = function (...args) { return (currentContext.it || currentContext.test).only.apply(this, args); }; -exports.it.skip = function(...args) { +exports.it.skip = function (...args) { return (currentContext.it || currentContext.test).skip.apply(this, args); }; exports.xdescribe = exports.describe.skip; @@ -144,7 +141,7 @@ exports.suiteTeardown = exports.after; exports.suite = exports.describe; exports.teardown = exports.afterEach; exports.test = exports.it; -exports.run = function(...args) { +exports.run = function (...args) { return currentContext.run.apply(this, args); }; @@ -229,7 +226,7 @@ function Mocha(options = {}) { 'growl', 'inlineDiffs', 'invert' - ].forEach(function(opt) { + ].forEach(function (opt) { if (options[opt]) { this[opt](); } @@ -287,7 +284,7 @@ function Mocha(options = {}) { * @returns {Mocha} this * @chainable */ -Mocha.prototype.bail = function(bail) { +Mocha.prototype.bail = function (bail) { this.suite.bail(bail !== false); return this; }; @@ -305,7 +302,7 @@ Mocha.prototype.bail = function(bail) { * @returns {Mocha} this * @chainable */ -Mocha.prototype.addFile = function(file) { +Mocha.prototype.addFile = function (file) { this.files.push(file); return this; }; @@ -326,7 +323,7 @@ Mocha.prototype.addFile = function(file) { * // Use XUnit reporter and direct its output to file * mocha.reporter('xunit', { output: '/path/to/testspec.xunit.xml' }); */ -Mocha.prototype.reporter = function(reporterName, reporterOptions) { +Mocha.prototype.reporter = function (reporterName, reporterOptions) { if (typeof reporterName === 'function') { this._reporter = reporterName; } else { @@ -382,7 +379,7 @@ Mocha.prototype.reporter = function(reporterName, reporterOptions) { * @chainable * @throws {Error} if requested interface cannot be loaded */ -Mocha.prototype.ui = function(ui) { +Mocha.prototype.ui = function (ui) { var bindInterface; if (typeof ui === 'function') { bindInterface = ui; @@ -399,7 +396,7 @@ Mocha.prototype.ui = function(ui) { } bindInterface(this.suite); - this.suite.on(EVENT_FILE_PRE_REQUIRE, function(context) { + this.suite.on(EVENT_FILE_PRE_REQUIRE, function (context) { currentContext = context; }); @@ -421,10 +418,10 @@ Mocha.prototype.ui = function(ui) { * @see {@link Mocha#loadFilesAsync} * @param {Function} [fn] - Callback invoked upon completion. */ -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(EVENT_FILE_PRE_REQUIRE, global, file, self); suite.emit(EVENT_FILE_REQUIRE, require(file), file, self); @@ -453,17 +450,17 @@ Mocha.prototype.loadFiles = function(fn) { * .then(() => mocha.run(failures => process.exitCode = failures ? 1 : 0)) * .catch(() => process.exitCode = 1); */ -Mocha.prototype.loadFilesAsync = function() { +Mocha.prototype.loadFilesAsync = function () { var self = this; var suite = this.suite; this.lazyLoadFiles(true); return esmUtils.loadFilesAsync( this.files, - function(file) { + function (file) { suite.emit(EVENT_FILE_PRE_REQUIRE, global, file, self); }, - function(file, resultModule) { + function (file, resultModule) { suite.emit(EVENT_FILE_REQUIRE, resultModule, file, self); suite.emit(EVENT_FILE_POST_REQUIRE, global, file, self); } @@ -478,7 +475,7 @@ Mocha.prototype.loadFilesAsync = function() { * @see {@link Mocha#unloadFiles} * @param {string} file - Pathname of file to be unloaded. */ -Mocha.unloadFile = function(file) { +Mocha.unloadFile = function (file) { if (utils.isBrowser()) { throw createUnsupportedError( 'unloadFile() is only suported in a Node.js environment' @@ -502,7 +499,7 @@ Mocha.unloadFile = function(file) { * @returns {Mocha} this * @chainable */ -Mocha.prototype.unloadFiles = function() { +Mocha.prototype.unloadFiles = function () { if (this._state === mochaStates.DISPOSED) { throw createMochaInstanceAlreadyDisposedError( 'Mocha instance is already disposed, it cannot be used again.', @@ -511,7 +508,7 @@ Mocha.prototype.unloadFiles = function() { ); } - this.files.forEach(function(file) { + this.files.forEach(function (file) { Mocha.unloadFile(file); }); this._state = mochaStates.INIT; @@ -531,7 +528,7 @@ Mocha.prototype.unloadFiles = function() { * // Select tests whose full title begins with `"foo"` followed by a period * mocha.fgrep('foo.'); */ -Mocha.prototype.fgrep = function(str) { +Mocha.prototype.fgrep = function (str) { if (!str) { return this; } @@ -572,7 +569,7 @@ Mocha.prototype.fgrep = function(str) { * // Given embedded test `it('only-this-test')`... * mocha.grep('/^only-this-test$/'); // NO! Use `.only()` to do this! */ -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(/^\/(.*)\/([gimy]{0,4})$|.*/); @@ -595,7 +592,7 @@ Mocha.prototype.grep = function(re) { * // Select tests whose full title does *not* contain `"match"`, ignoring case * mocha.grep(/match/i).invert(); */ -Mocha.prototype.invert = function() { +Mocha.prototype.invert = function () { this.options.invert = true; return this; }; @@ -609,7 +606,7 @@ Mocha.prototype.invert = function() { * @return {Mocha} this * @chainable */ -Mocha.prototype.checkLeaks = function(checkLeaks) { +Mocha.prototype.checkLeaks = function (checkLeaks) { this.options.checkLeaks = checkLeaks !== false; return this; }; @@ -624,7 +621,7 @@ Mocha.prototype.checkLeaks = function(checkLeaks) { * @return {Mocha} this * @chainable */ -Mocha.prototype.cleanReferencesAfterRun = function(cleanReferencesAfterRun) { +Mocha.prototype.cleanReferencesAfterRun = function (cleanReferencesAfterRun) { this._cleanReferencesAfterRun = cleanReferencesAfterRun !== false; return this; }; @@ -634,7 +631,7 @@ Mocha.prototype.cleanReferencesAfterRun = function(cleanReferencesAfterRun) { * It also removes function references to tests functions and hooks, so variables trapped in closures can be cleaned by the garbage collector. * @public */ -Mocha.prototype.dispose = function() { +Mocha.prototype.dispose = function () { if (this._state === mochaStates.RUNNING) { throw createMochaInstanceAlreadyRunningError( 'Cannot dispose while the mocha instance is still running tests.' @@ -655,7 +652,7 @@ Mocha.prototype.dispose = function() { * @return {Mocha} this * @chainable */ -Mocha.prototype.fullTrace = function(fullTrace) { +Mocha.prototype.fullTrace = function (fullTrace) { this.options.fullTrace = fullTrace !== false; return this; }; @@ -668,7 +665,7 @@ Mocha.prototype.fullTrace = function(fullTrace) { * @return {Mocha} this * @chainable */ -Mocha.prototype.growl = function() { +Mocha.prototype.growl = function () { this.options.growl = this.isGrowlCapable(); if (!this.options.growl) { var detail = utils.isBrowser() @@ -717,11 +714,11 @@ Mocha.prototype._growl = growl.notify; * // Specify variables to be expected in global scope * mocha.global(['jQuery', 'MyLib']); */ -Mocha.prototype.global = function(global) { +Mocha.prototype.global = function (global) { this.options.global = (this.options.global || []) .concat(global) .filter(Boolean) - .filter(function(elt, idx, arr) { + .filter(function (elt, idx, arr) { return arr.indexOf(elt) === idx; }); return this; @@ -738,7 +735,7 @@ Mocha.prototype.globals = Mocha.prototype.global; * @return {Mocha} this * @chainable */ -Mocha.prototype.color = function(color) { +Mocha.prototype.color = function (color) { this.options.color = color !== false; return this; }; @@ -753,7 +750,7 @@ Mocha.prototype.color = function(color) { * @return {Mocha} this * @chainable */ -Mocha.prototype.inlineDiffs = function(inlineDiffs) { +Mocha.prototype.inlineDiffs = function (inlineDiffs) { this.options.inlineDiffs = inlineDiffs !== false; return this; }; @@ -767,7 +764,7 @@ Mocha.prototype.inlineDiffs = function(inlineDiffs) { * @return {Mocha} this * @chainable */ -Mocha.prototype.diff = function(diff) { +Mocha.prototype.diff = function (diff) { this.options.diff = diff !== false; return this; }; @@ -795,7 +792,7 @@ Mocha.prototype.diff = function(diff) { * // Same as above but using string argument * mocha.timeout('1s'); */ -Mocha.prototype.timeout = function(msecs) { +Mocha.prototype.timeout = function (msecs) { this.suite.timeout(msecs); return this; }; @@ -814,7 +811,7 @@ Mocha.prototype.timeout = function(msecs) { * // Allow any failed test to retry one more time * mocha.retries(1); */ -Mocha.prototype.retries = function(retry) { +Mocha.prototype.retries = function (retry) { this.suite.retries(retry); return this; }; @@ -836,7 +833,7 @@ Mocha.prototype.retries = function(retry) { * // Same as above but using string argument * mocha.slow('0.5s'); */ -Mocha.prototype.slow = function(msecs) { +Mocha.prototype.slow = function (msecs) { this.suite.slow(msecs); return this; }; @@ -850,7 +847,7 @@ Mocha.prototype.slow = function(msecs) { * @return {Mocha} this * @chainable */ -Mocha.prototype.asyncOnly = function(asyncOnly) { +Mocha.prototype.asyncOnly = function (asyncOnly) { this.options.asyncOnly = asyncOnly !== false; return this; }; @@ -862,7 +859,7 @@ Mocha.prototype.asyncOnly = function(asyncOnly) { * @return {Mocha} this * @chainable */ -Mocha.prototype.noHighlighting = function() { +Mocha.prototype.noHighlighting = function () { this.options.noHighlighting = true; return this; }; @@ -876,7 +873,7 @@ Mocha.prototype.noHighlighting = function() { * @return {Mocha} this * @chainable */ -Mocha.prototype.allowUncaught = function(allowUncaught) { +Mocha.prototype.allowUncaught = function (allowUncaught) { this.options.allowUncaught = allowUncaught !== false; return this; }; @@ -907,7 +904,7 @@ Mocha.prototype.delay = function delay() { * @return {Mocha} this * @chainable */ -Mocha.prototype.dryRun = function(dryRun) { +Mocha.prototype.dryRun = function (dryRun) { this.options.dryRun = dryRun !== false; return this; }; @@ -921,7 +918,7 @@ Mocha.prototype.dryRun = function(dryRun) { * @return {Mocha} this * @chainable */ -Mocha.prototype.failZero = function(failZero) { +Mocha.prototype.failZero = function (failZero) { this.options.failZero = failZero !== false; return this; }; @@ -935,7 +932,7 @@ Mocha.prototype.failZero = function(failZero) { * @returns {Mocha} this * @chainable */ -Mocha.prototype.forbidOnly = function(forbidOnly) { +Mocha.prototype.forbidOnly = function (forbidOnly) { this.options.forbidOnly = forbidOnly !== false; return this; }; @@ -949,7 +946,7 @@ Mocha.prototype.forbidOnly = function(forbidOnly) { * @returns {Mocha} this * @chainable */ -Mocha.prototype.forbidPending = function(forbidPending) { +Mocha.prototype.forbidPending = function (forbidPending) { this.options.forbidPending = forbidPending !== false; return this; }; @@ -958,7 +955,7 @@ Mocha.prototype.forbidPending = function(forbidPending) { * Throws an error if mocha is in the wrong state to be able to transition to a "running" state. * @private */ -Mocha.prototype._guardRunningStateTransition = function() { +Mocha.prototype._guardRunningStateTransition = function () { if (this._state === mochaStates.RUNNING) { throw createMochaInstanceAlreadyRunningError( 'Mocha instance is currently running tests, cannot start a next test run until this one is done', @@ -1017,7 +1014,7 @@ Object.defineProperty(Mocha.prototype, 'version', { * // exit with non-zero status if there were test failures * mocha.run(failures => process.exitCode = failures ? 1 : 0); */ -Mocha.prototype.run = function(fn) { +Mocha.prototype.run = function (fn) { this._guardRunningStateTransition(); this._state = mochaStates.RUNNING; if (this._previousRunner) { @@ -1320,9 +1317,10 @@ Mocha.prototype.hasGlobalSetupFixtures = function hasGlobalSetupFixtures() { * @public * @returns {boolean} */ -Mocha.prototype.hasGlobalTeardownFixtures = function hasGlobalTeardownFixtures() { - return Boolean(this.options.globalTeardown.length); -}; +Mocha.prototype.hasGlobalTeardownFixtures = + function hasGlobalTeardownFixtures() { + return Boolean(this.options.globalTeardown.length); + }; /** * An alternative way to define root hooks that works with parallel runs. diff --git a/lib/reporters/base.js b/lib/reporters/base.js index f2f2bc65fc..90f89c99bf 100644 --- a/lib/reporters/base.js +++ b/lib/reporters/base.js @@ -107,7 +107,7 @@ exports.symbols = { * @param {string} str * @return {string} */ -var color = (exports.color = function(type, str) { +var color = (exports.color = function (type, str) { if (!exports.useColors) { return String(str); } @@ -135,23 +135,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(); @@ -161,7 +161,7 @@ exports.cursor = { } }; -var showDiff = (exports.showDiff = function(err) { +var showDiff = (exports.showDiff = function (err) { return ( err && err.showDiff !== false && @@ -188,7 +188,7 @@ function stringifyDiffObjs(err) { * @param {string} expected * @return {string} Diff */ -var generateDiff = (exports.generateDiff = function(actual, expected) { +var generateDiff = (exports.generateDiff = function (actual, expected) { try { const diffSize = 2048; if (actual.length > diffSize) { @@ -220,10 +220,10 @@ var generateDiff = (exports.generateDiff = function(actual, expected) { * @param {Object[]} failures - Each is Test instance with corresponding * Error property */ -exports.list = function(failures) { +exports.list = function (failures) { var multipleErr, multipleTest; Base.consoleLog(); - failures.forEach(function(test, i) { + failures.forEach(function (test, i) { // format var fmt = color('error title', ' %s) %s:\n') + @@ -282,7 +282,7 @@ exports.list = function(failures) { // indented test title var testTitle = ''; - test.titlePath().forEach(function(str, index) { + test.titlePath().forEach(function (str, index) { if (index !== 0) { testTitle += '\n '; } @@ -318,7 +318,7 @@ function Base(runner, options) { this.runner = runner; this.stats = runner.stats; // assigned so Reporters keep a closer reference - runner.on(EVENT_TEST_PASS, function(test) { + runner.on(EVENT_TEST_PASS, function (test) { if (test.duration > test.slow()) { test.speed = 'slow'; } else if (test.duration > test.slow() / 2) { @@ -328,7 +328,7 @@ function Base(runner, options) { } }); - runner.on(EVENT_TEST_FAIL, function(test, err) { + runner.on(EVENT_TEST_FAIL, function (test, err) { if (showDiff(err)) { stringifyDiffObjs(err); } @@ -348,7 +348,7 @@ function Base(runner, options) { * @public * @memberof Mocha.reporters */ -Base.prototype.epilogue = function() { +Base.prototype.epilogue = function () { var stats = this.stats; var fmt; @@ -411,7 +411,7 @@ function inlineDiff(actual, expected) { if (lines.length > 4) { var width = String(lines.length).length; msg = lines - .map(function(str, i) { + .map(function (str, i) { return pad(++i, width) + ' |' + ' ' + str; }) .join('\n'); @@ -468,10 +468,7 @@ function unifiedDiff(actual, expected) { ' ' + colorLines('diff removed', '- actual') + '\n\n' + - lines - .map(cleanUp) - .filter(notBlank) - .join('\n') + lines.map(cleanUp).filter(notBlank).join('\n') ); } @@ -486,7 +483,7 @@ function unifiedDiff(actual, expected) { function errorDiff(actual, expected) { return diff .diffWordsWithSpace(actual, expected) - .map(function(str) { + .map(function (str) { if (str.added) { return colorLines('diff added inline', str.value); } @@ -509,7 +506,7 @@ function errorDiff(actual, expected) { function colorLines(name, str) { return str .split('\n') - .map(function(str) { + .map(function (str) { return color(name, str); }) .join('\n'); diff --git a/lib/reporters/doc.js b/lib/reporters/doc.js index fd6b46932d..b2c3e48807 100644 --- a/lib/reporters/doc.js +++ b/lib/reporters/doc.js @@ -39,7 +39,7 @@ function Doc(runner, options) { return Array(indents).join(' '); } - runner.on(EVENT_SUITE_BEGIN, function(suite) { + runner.on(EVENT_SUITE_BEGIN, function (suite) { if (suite.root) { return; } @@ -50,7 +50,7 @@ function Doc(runner, options) { Base.consoleLog('%s
', indent()); }); - runner.on(EVENT_SUITE_END, function(suite) { + runner.on(EVENT_SUITE_END, function (suite) { if (suite.root) { return; } @@ -60,14 +60,14 @@ function Doc(runner, options) { --indents; }); - runner.on(EVENT_TEST_PASS, function(test) { + runner.on(EVENT_TEST_PASS, function (test) { Base.consoleLog('%s
%s
', indent(), utils.escape(test.title)); Base.consoleLog('%s
%s
', indent(), utils.escape(test.file)); var code = utils.escape(utils.clean(test.body)); Base.consoleLog('%s
%s
', indent(), code); }); - runner.on(EVENT_TEST_FAIL, function(test, err) { + runner.on(EVENT_TEST_FAIL, function (test, err) { Base.consoleLog( '%s
%s
', indent(), diff --git a/lib/reporters/dot.js b/lib/reporters/dot.js index 3913f0c679..c67ac8ff06 100644 --- a/lib/reporters/dot.js +++ b/lib/reporters/dot.js @@ -38,18 +38,18 @@ function Dot(runner, options) { var width = (Base.window.width * 0.75) | 0; var n = -1; - runner.on(EVENT_RUN_BEGIN, function() { + runner.on(EVENT_RUN_BEGIN, function () { process.stdout.write('\n'); }); - runner.on(EVENT_TEST_PENDING, function() { + runner.on(EVENT_TEST_PENDING, function () { if (++n % width === 0) { process.stdout.write('\n '); } process.stdout.write(Base.color('pending', Base.symbols.comma)); }); - runner.on(EVENT_TEST_PASS, function(test) { + runner.on(EVENT_TEST_PASS, function (test) { if (++n % width === 0) { process.stdout.write('\n '); } @@ -60,14 +60,14 @@ function Dot(runner, options) { } }); - runner.on(EVENT_TEST_FAIL, function() { + runner.on(EVENT_TEST_FAIL, function () { if (++n % width === 0) { process.stdout.write('\n '); } process.stdout.write(Base.color('fail', Base.symbols.bang)); }); - runner.once(EVENT_RUN_END, function() { + runner.once(EVENT_RUN_END, function () { process.stdout.write('\n'); self.epilogue(); }); diff --git a/lib/reporters/html.js b/lib/reporters/html.js index 70e8698407..f0fb538a91 100644 --- a/lib/reporters/html.js +++ b/lib/reporters/html.js @@ -91,7 +91,7 @@ function HTML(runner, options) { } // pass toggle - on(passesLink, 'click', function(evt) { + on(passesLink, 'click', function (evt) { evt.preventDefault(); unhide(); var name = /pass/.test(report.className) ? '' : ' pass'; @@ -102,7 +102,7 @@ function HTML(runner, options) { }); // failure toggle - on(failuresLink, 'click', function(evt) { + on(failuresLink, 'click', function (evt) { evt.preventDefault(); unhide(); var name = /fail/.test(report.className) ? '' : ' fail'; @@ -119,7 +119,7 @@ function HTML(runner, options) { progress.size(40); } - runner.on(EVENT_SUITE_BEGIN, function(suite) { + runner.on(EVENT_SUITE_BEGIN, function (suite) { if (suite.root) { return; } @@ -138,7 +138,7 @@ function HTML(runner, options) { el.appendChild(stack[0]); }); - runner.on(EVENT_SUITE_END, function(suite) { + runner.on(EVENT_SUITE_END, function (suite) { if (suite.root) { updateStats(); return; @@ -146,7 +146,7 @@ function HTML(runner, options) { stack.shift(); }); - runner.on(EVENT_TEST_PASS, function(test) { + runner.on(EVENT_TEST_PASS, function (test) { var url = self.testURL(test); var markup = '
  • %e%ems ' + @@ -159,7 +159,7 @@ function HTML(runner, options) { updateStats(); }); - runner.on(EVENT_TEST_FAIL, function(test) { + runner.on(EVENT_TEST_FAIL, function (test) { var el = fragment( '
  • %e ' + playIcon + @@ -215,7 +215,7 @@ function HTML(runner, options) { updateStats(); }); - runner.on(EVENT_TEST_PENDING, function(test) { + runner.on(EVENT_TEST_PENDING, function (test) { var el = fragment( '
  • %e

  • ', test.title @@ -273,7 +273,7 @@ function makeUrl(s) { * * @param {Object} [suite] */ -HTML.prototype.suiteURL = function(suite) { +HTML.prototype.suiteURL = function (suite) { return makeUrl(suite.fullTitle()); }; @@ -282,7 +282,7 @@ HTML.prototype.suiteURL = function(suite) { * * @param {Object} [test] */ -HTML.prototype.testURL = function(test) { +HTML.prototype.testURL = function (test) { return makeUrl(test.fullTitle()); }; @@ -292,10 +292,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'; }); @@ -323,7 +323,7 @@ function fragment(html) { 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++]); diff --git a/lib/reporters/json-stream.js b/lib/reporters/json-stream.js index 87cf607282..b20c000d37 100644 --- a/lib/reporters/json-stream.js +++ b/lib/reporters/json-stream.js @@ -35,22 +35,22 @@ function JSONStream(runner, options) { var self = this; var total = runner.total; - runner.once(EVENT_RUN_BEGIN, function() { + runner.once(EVENT_RUN_BEGIN, function () { writeEvent(['start', {total: total}]); }); - runner.on(EVENT_TEST_PASS, function(test) { + runner.on(EVENT_TEST_PASS, function (test) { writeEvent(['pass', clean(test)]); }); - runner.on(EVENT_TEST_FAIL, function(test, err) { + runner.on(EVENT_TEST_FAIL, function (test, err) { test = clean(test); test.err = err.message; test.stack = err.stack || null; writeEvent(['fail', test]); }); - runner.once(EVENT_RUN_END, function() { + runner.once(EVENT_RUN_END, function () { writeEvent(['end', self.stats]); }); } diff --git a/lib/reporters/json.js b/lib/reporters/json.js index 05e6269361..6194d8747d 100644 --- a/lib/reporters/json.js +++ b/lib/reporters/json.js @@ -51,23 +51,23 @@ function JSONReporter(runner, options = {}) { output = options.reporterOption.output; } - runner.on(EVENT_TEST_END, function(test) { + runner.on(EVENT_TEST_END, function (test) { tests.push(test); }); - runner.on(EVENT_TEST_PASS, function(test) { + runner.on(EVENT_TEST_PASS, function (test) { passes.push(test); }); - runner.on(EVENT_TEST_FAIL, function(test) { + runner.on(EVENT_TEST_FAIL, function (test) { failures.push(test); }); - runner.on(EVENT_TEST_PENDING, function(test) { + runner.on(EVENT_TEST_PENDING, function (test) { pending.push(test); }); - runner.once(EVENT_RUN_END, function() { + runner.once(EVENT_RUN_END, function () { var obj = { stats: self.stats, tests: tests.map(clean), @@ -130,7 +130,7 @@ function clean(test) { function cleanCycles(obj) { var cache = []; return JSON.parse( - JSON.stringify(obj, function(key, value) { + JSON.stringify(obj, function (key, value) { if (typeof value === 'object' && value !== null) { if (cache.indexOf(value) !== -1) { // Instead of going in a circle, we'll print [object Object] @@ -153,7 +153,7 @@ function cleanCycles(obj) { */ 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.js index 03c9acb1af..4188c7cdd4 100644 --- a/lib/reporters/landing.js +++ b/lib/reporters/landing.js @@ -68,12 +68,12 @@ function Landing(runner, options) { return ' ' + color('runway', buf); } - runner.on(EVENT_RUN_BEGIN, function() { + runner.on(EVENT_RUN_BEGIN, function () { stream.write('\n\n\n '); cursor.hide(); }); - runner.on(EVENT_TEST_END, function(test) { + runner.on(EVENT_TEST_END, function (test) { // check if the plane crashed var col = crashed === -1 ? ((width * ++n) / ++total) | 0 : crashed; // show the crash @@ -93,16 +93,16 @@ function Landing(runner, options) { stream.write('\u001b[0m'); }); - runner.once(EVENT_RUN_END, function() { + runner.once(EVENT_RUN_END, function () { cursor.show(); process.stdout.write('\n'); self.epilogue(); }); // if cursor is hidden when we ctrl-C, then it will remain hidden unless... - process.once('SIGINT', function() { + process.once('SIGINT', function () { cursor.show(); - process.nextTick(function() { + process.nextTick(function () { process.kill(process.pid, 'SIGINT'); }); }); diff --git a/lib/reporters/list.js b/lib/reporters/list.js index c7ff8c4ea8..aebdd65e1f 100644 --- a/lib/reporters/list.js +++ b/lib/reporters/list.js @@ -40,20 +40,20 @@ function List(runner, options) { var self = this; var n = 0; - runner.on(EVENT_RUN_BEGIN, function() { + runner.on(EVENT_RUN_BEGIN, function () { Base.consoleLog(); }); - runner.on(EVENT_TEST_BEGIN, function(test) { + runner.on(EVENT_TEST_BEGIN, function (test) { process.stdout.write(color('pass', ' ' + test.fullTitle() + ': ')); }); - runner.on(EVENT_TEST_PENDING, function(test) { + runner.on(EVENT_TEST_PENDING, function (test) { var fmt = color('checkmark', ' -') + color('pending', ' %s'); Base.consoleLog(fmt, test.fullTitle()); }); - runner.on(EVENT_TEST_PASS, function(test) { + runner.on(EVENT_TEST_PASS, function (test) { var fmt = color('checkmark', ' ' + Base.symbols.ok) + color('pass', ' %s: ') + @@ -62,7 +62,7 @@ function List(runner, options) { Base.consoleLog(fmt, test.fullTitle(), test.duration); }); - runner.on(EVENT_TEST_FAIL, function(test) { + runner.on(EVENT_TEST_FAIL, function (test) { cursor.CR(); Base.consoleLog(color('fail', ' %d) %s'), ++n, test.fullTitle()); }); diff --git a/lib/reporters/markdown.js b/lib/reporters/markdown.js index 460e248405..f65726fcfd 100644 --- a/lib/reporters/markdown.js +++ b/lib/reporters/markdown.js @@ -51,7 +51,7 @@ function Markdown(runner, options) { 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); }); @@ -83,18 +83,18 @@ function Markdown(runner, options) { generateTOC(runner.suite); - runner.on(EVENT_SUITE_BEGIN, function(suite) { + runner.on(EVENT_SUITE_BEGIN, function (suite) { ++level; var slug = utils.slug(suite.fullTitle()); buf += '
    ' + '\n'; buf += title(suite.title) + '\n'; }); - runner.on(EVENT_SUITE_END, function() { + runner.on(EVENT_SUITE_END, function () { --level; }); - runner.on(EVENT_TEST_PASS, function(test) { + runner.on(EVENT_TEST_PASS, function (test) { var code = utils.clean(test.body); buf += test.title + '.\n'; buf += '\n```js\n'; @@ -102,7 +102,7 @@ function Markdown(runner, options) { buf += '```\n\n'; }); - runner.once(EVENT_RUN_END, function() { + runner.once(EVENT_RUN_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.js index 019ffe595a..4de98e6f9b 100644 --- a/lib/reporters/min.js +++ b/lib/reporters/min.js @@ -34,7 +34,7 @@ exports = module.exports = Min; function Min(runner, options) { Base.call(this, runner, options); - runner.on(EVENT_RUN_BEGIN, function() { + runner.on(EVENT_RUN_BEGIN, function () { // clear screen process.stdout.write('\u001b[2J'); // set cursor position diff --git a/lib/reporters/nyan.js b/lib/reporters/nyan.js index 4eda971e7c..e7b3fa8f65 100644 --- a/lib/reporters/nyan.js +++ b/lib/reporters/nyan.js @@ -46,24 +46,24 @@ function NyanCat(runner, options) { this.trajectories = [[], [], [], []]; this.trajectoryWidthMax = width - nyanCatWidth; - runner.on(EVENT_RUN_BEGIN, function() { + runner.on(EVENT_RUN_BEGIN, function () { Base.cursor.hide(); self.draw(); }); - runner.on(EVENT_TEST_PENDING, function() { + runner.on(EVENT_TEST_PENDING, function () { self.draw(); }); - runner.on(EVENT_TEST_PASS, function() { + runner.on(EVENT_TEST_PASS, function () { self.draw(); }); - runner.on(EVENT_TEST_FAIL, function() { + runner.on(EVENT_TEST_FAIL, function () { self.draw(); }); - runner.once(EVENT_RUN_END, function() { + runner.once(EVENT_RUN_END, function () { Base.cursor.show(); for (var i = 0; i < self.numberOfLines; i++) { write('\n'); @@ -83,7 +83,7 @@ inherits(NyanCat, Base); * @private */ -NyanCat.prototype.draw = function() { +NyanCat.prototype.draw = function () { this.appendRainbow(); this.drawScoreboard(); this.drawRainbow(); @@ -98,7 +98,7 @@ NyanCat.prototype.draw = function() { * @private */ -NyanCat.prototype.drawScoreboard = function() { +NyanCat.prototype.drawScoreboard = function () { var stats = this.stats; function draw(type, n) { @@ -121,7 +121,7 @@ NyanCat.prototype.drawScoreboard = function() { * @private */ -NyanCat.prototype.appendRainbow = function() { +NyanCat.prototype.appendRainbow = function () { var segment = this.tick ? '_' : '-'; var rainbowified = this.rainbowify(segment); @@ -140,10 +140,10 @@ NyanCat.prototype.appendRainbow = function() { * @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'); @@ -157,7 +157,7 @@ NyanCat.prototype.drawRainbow = function() { * * @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'; @@ -193,7 +193,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)'; @@ -212,7 +212,7 @@ NyanCat.prototype.face = function() { * @param {number} n */ -NyanCat.prototype.cursorUp = function(n) { +NyanCat.prototype.cursorUp = function (n) { write('\u001b[' + n + 'A'); }; @@ -223,7 +223,7 @@ NyanCat.prototype.cursorUp = function(n) { * @param {number} n */ -NyanCat.prototype.cursorDown = function(n) { +NyanCat.prototype.cursorDown = function (n) { write('\u001b[' + n + 'B'); }; @@ -233,7 +233,7 @@ NyanCat.prototype.cursorDown = function(n) { * @private * @return {Array} */ -NyanCat.prototype.generateColors = function() { +NyanCat.prototype.generateColors = function () { var colors = []; for (var i = 0; i < 6 * 7; i++) { @@ -255,7 +255,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; } diff --git a/lib/reporters/progress.js b/lib/reporters/progress.js index 0211122a9d..4f6d8794af 100644 --- a/lib/reporters/progress.js +++ b/lib/reporters/progress.js @@ -57,13 +57,13 @@ function Progress(runner, options) { options.verbose = reporterOptions.verbose || false; // tests started - runner.on(EVENT_RUN_BEGIN, function() { + runner.on(EVENT_RUN_BEGIN, function () { process.stdout.write('\n'); cursor.hide(); }); // tests complete - runner.on(EVENT_TEST_END, function() { + runner.on(EVENT_TEST_END, function () { complete++; var percent = complete / total; @@ -89,7 +89,7 @@ function Progress(runner, options) { // tests are complete, output some stats // and the failures if any - runner.once(EVENT_RUN_END, function() { + runner.once(EVENT_RUN_END, function () { cursor.show(); process.stdout.write('\n'); self.epilogue(); diff --git a/lib/reporters/spec.js b/lib/reporters/spec.js index e51ed80ac4..8497249f73 100644 --- a/lib/reporters/spec.js +++ b/lib/reporters/spec.js @@ -45,28 +45,28 @@ function Spec(runner, options) { return Array(indents).join(' '); } - runner.on(EVENT_RUN_BEGIN, function() { + runner.on(EVENT_RUN_BEGIN, function () { Base.consoleLog(); }); - runner.on(EVENT_SUITE_BEGIN, function(suite) { + runner.on(EVENT_SUITE_BEGIN, function (suite) { ++indents; Base.consoleLog(color('suite', '%s%s'), indent(), suite.title); }); - runner.on(EVENT_SUITE_END, function() { + runner.on(EVENT_SUITE_END, function () { --indents; if (indents === 1) { Base.consoleLog(); } }); - runner.on(EVENT_TEST_PENDING, function(test) { + runner.on(EVENT_TEST_PENDING, function (test) { var fmt = indent() + color('pending', ' - %s'); Base.consoleLog(fmt, test.title); }); - runner.on(EVENT_TEST_PASS, function(test) { + runner.on(EVENT_TEST_PASS, function (test) { var fmt; if (test.speed === 'fast') { fmt = @@ -84,7 +84,7 @@ function Spec(runner, options) { } }); - runner.on(EVENT_TEST_FAIL, function(test) { + runner.on(EVENT_TEST_FAIL, function (test) { Base.consoleLog(indent() + color('fail', ' %d) %s'), ++n, test.title); }); diff --git a/lib/reporters/tap.js b/lib/reporters/tap.js index aa79fb19f1..37fa8b57a0 100644 --- a/lib/reporters/tap.js +++ b/lib/reporters/tap.js @@ -49,27 +49,27 @@ function TAP(runner, options) { this._producer = createProducer(tapVersion); - runner.once(EVENT_RUN_BEGIN, function() { + runner.once(EVENT_RUN_BEGIN, function () { self._producer.writeVersion(); }); - runner.on(EVENT_TEST_END, function() { + runner.on(EVENT_TEST_END, function () { ++n; }); - runner.on(EVENT_TEST_PENDING, function(test) { + runner.on(EVENT_TEST_PENDING, function (test) { self._producer.writePending(n, test); }); - runner.on(EVENT_TEST_PASS, function(test) { + runner.on(EVENT_TEST_PASS, function (test) { self._producer.writePass(n, test); }); - runner.on(EVENT_TEST_FAIL, function(test, err) { + runner.on(EVENT_TEST_FAIL, function (test, err) { self._producer.writeFail(n, test, err); }); - runner.once(EVENT_RUN_END, function() { + runner.once(EVENT_RUN_END, function () { self._producer.writeEpilogue(runner.stats); }); } @@ -113,8 +113,8 @@ function println(format, varArgs) { */ function createProducer(tapVersion) { var producers = { - '12': new TAP12Producer(), - '13': new TAP13Producer() + 12: new TAP12Producer(), + 13: new TAP13Producer() }; var producer = producers[tapVersion]; @@ -144,7 +144,7 @@ function TAPProducer() {} * * @abstract */ -TAPProducer.prototype.writeVersion = function() {}; +TAPProducer.prototype.writeVersion = function () {}; /** * Writes the plan to reporter output stream. @@ -152,7 +152,7 @@ TAPProducer.prototype.writeVersion = function() {}; * @abstract * @param {number} ntests - Number of tests that are planned to run. */ -TAPProducer.prototype.writePlan = function(ntests) { +TAPProducer.prototype.writePlan = function (ntests) { println('%d..%d', 1, ntests); }; @@ -163,7 +163,7 @@ TAPProducer.prototype.writePlan = function(ntests) { * @param {number} n - Index of test that passed. * @param {Test} test - Instance containing test information. */ -TAPProducer.prototype.writePass = function(n, test) { +TAPProducer.prototype.writePass = function (n, test) { println('ok %d %s', n, title(test)); }; @@ -174,7 +174,7 @@ TAPProducer.prototype.writePass = function(n, test) { * @param {number} n - Index of test that was skipped. * @param {Test} test - Instance containing test information. */ -TAPProducer.prototype.writePending = function(n, test) { +TAPProducer.prototype.writePending = function (n, test) { println('ok %d %s # SKIP -', n, title(test)); }; @@ -186,7 +186,7 @@ TAPProducer.prototype.writePending = function(n, test) { * @param {Test} test - Instance containing test information. * @param {Error} err - Reason the test failed. */ -TAPProducer.prototype.writeFail = function(n, test, err) { +TAPProducer.prototype.writeFail = function (n, test, err) { println('not ok %d %s', n, title(test)); }; @@ -196,7 +196,7 @@ TAPProducer.prototype.writeFail = function(n, test, err) { * @abstract * @param {Object} stats - Object containing run statistics. */ -TAPProducer.prototype.writeEpilogue = function(stats) { +TAPProducer.prototype.writeEpilogue = function (stats) { // :TBD: Why is this not counting pending tests? println('# tests ' + (stats.passes + stats.failures)); println('# pass ' + stats.passes); @@ -222,7 +222,7 @@ function TAP12Producer() { * Writes that test failed to reporter output stream, with error formatting. * @override */ - this.writeFail = function(n, test, err) { + this.writeFail = function (n, test, err) { TAPProducer.prototype.writeFail.call(this, n, test, err); if (err.message) { println(err.message.replace(/^/gm, ' ')); @@ -255,7 +255,7 @@ function TAP13Producer() { * Writes the TAP version to reporter output stream. * @override */ - this.writeVersion = function() { + this.writeVersion = function () { println('TAP version 13'); }; @@ -263,7 +263,7 @@ function TAP13Producer() { * Writes that test failed to reporter output stream, with error formatting. * @override */ - this.writeFail = function(n, test, err) { + this.writeFail = function (n, test, err) { TAPProducer.prototype.writeFail.call(this, n, test, err); var emitYamlBlock = err.message != null || err.stack != null; if (emitYamlBlock) { diff --git a/lib/reporters/xunit.js b/lib/reporters/xunit.js index a690ac5343..ec788c5da0 100644 --- a/lib/reporters/xunit.js +++ b/lib/reporters/xunit.js @@ -74,19 +74,19 @@ function XUnit(runner, options) { // fall back to the default suite name suiteName = suiteName || DEFAULT_SUITE_NAME; - runner.on(EVENT_TEST_PENDING, function(test) { + runner.on(EVENT_TEST_PENDING, function (test) { tests.push(test); }); - runner.on(EVENT_TEST_PASS, function(test) { + runner.on(EVENT_TEST_PASS, function (test) { tests.push(test); }); - runner.on(EVENT_TEST_FAIL, function(test) { + runner.on(EVENT_TEST_FAIL, function (test) { tests.push(test); }); - runner.once(EVENT_RUN_END, function() { + runner.once(EVENT_RUN_END, function () { self.write( tag( 'testsuite', @@ -103,7 +103,7 @@ function XUnit(runner, options) { ) ); - tests.forEach(function(t) { + tests.forEach(function (t) { self.test(t); }); @@ -122,9 +122,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 { @@ -137,7 +137,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) { @@ -152,7 +152,7 @@ XUnit.prototype.write = function(line) { * * @param {Test} test */ -XUnit.prototype.test = function(test) { +XUnit.prototype.test = function (test) { Base.useColors = false; var attrs = { diff --git a/lib/runnable.js b/lib/runnable.js index 3b59680e6a..fef4941024 100644 --- a/lib/runnable.js +++ b/lib/runnable.js @@ -57,7 +57,7 @@ utils.inherits(Runnable, EventEmitter); /** * Resets the state initially or for a next run. */ -Runnable.prototype.reset = function() { +Runnable.prototype.reset = function () { this.timedOut = false; this._currentRetry = 0; this.pending = false; @@ -86,7 +86,7 @@ Runnable.prototype.reset = function() { * @returns {Runnable} this * @chainable */ -Runnable.prototype.timeout = function(ms) { +Runnable.prototype.timeout = function (ms) { if (!arguments.length) { return this._timeout; } @@ -120,7 +120,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 (!arguments.length || typeof ms === 'undefined') { return this._slow; } @@ -138,7 +138,7 @@ Runnable.prototype.slow = function(ms) { * @memberof Mocha.Runnable * @public */ -Runnable.prototype.skip = function() { +Runnable.prototype.skip = function () { this.pending = true; throw new Pending('sync skip; aborting execution'); }; @@ -148,7 +148,7 @@ Runnable.prototype.skip = function() { * * @private */ -Runnable.prototype.isPending = function() { +Runnable.prototype.isPending = function () { return this.pending || (this.parent && this.parent.isPending()); }; @@ -157,7 +157,7 @@ Runnable.prototype.isPending = function() { * @return {boolean} * @private */ -Runnable.prototype.isFailed = function() { +Runnable.prototype.isFailed = function () { return !this.isPending() && this.state === constants.STATE_FAILED; }; @@ -166,7 +166,7 @@ Runnable.prototype.isFailed = function() { * @return {boolean} * @private */ -Runnable.prototype.isPassed = function() { +Runnable.prototype.isPassed = function () { return !this.isPending() && this.state === constants.STATE_PASSED; }; @@ -175,7 +175,7 @@ Runnable.prototype.isPassed = function() { * * @private */ -Runnable.prototype.retries = function(n) { +Runnable.prototype.retries = function (n) { if (!arguments.length) { return this._retries; } @@ -187,7 +187,7 @@ Runnable.prototype.retries = function(n) { * * @private */ -Runnable.prototype.currentRetry = function(n) { +Runnable.prototype.currentRetry = function (n) { if (!arguments.length) { return this._currentRetry; } @@ -202,7 +202,7 @@ Runnable.prototype.currentRetry = function(n) { * @public * @return {string} */ -Runnable.prototype.fullTitle = function() { +Runnable.prototype.fullTitle = function () { return this.titlePath().join(' '); }; @@ -213,7 +213,7 @@ Runnable.prototype.fullTitle = function() { * @public * @return {string} */ -Runnable.prototype.titlePath = function() { +Runnable.prototype.titlePath = function () { return this.parent.titlePath().concat([this.title]); }; @@ -222,7 +222,7 @@ Runnable.prototype.titlePath = function() { * * @private */ -Runnable.prototype.clearTimeout = function() { +Runnable.prototype.clearTimeout = function () { clearTimeout(this.timer); }; @@ -231,7 +231,7 @@ Runnable.prototype.clearTimeout = function() { * * @private */ -Runnable.prototype.resetTimeout = function() { +Runnable.prototype.resetTimeout = function () { var self = this; var ms = this.timeout(); @@ -239,7 +239,7 @@ Runnable.prototype.resetTimeout = function() { return; } this.clearTimeout(); - this.timer = setTimeout(function() { + this.timer = setTimeout(function () { if (self.timeout() === 0) { return; } @@ -254,7 +254,7 @@ Runnable.prototype.resetTimeout = function() { * @private * @param {string[]} globals */ -Runnable.prototype.globals = function(globals) { +Runnable.prototype.globals = function (globals) { if (!arguments.length) { return this._allowedGlobals; } @@ -267,7 +267,7 @@ Runnable.prototype.globals = function(globals) { * @param {Function} fn * @private */ -Runnable.prototype.run = function(fn) { +Runnable.prototype.run = function (fn) { var self = this; var start = new Date(); var ctx = this.ctx; @@ -367,13 +367,13 @@ Runnable.prototype.run = function(fn) { if (result && typeof result.then === 'function') { self.resetTimeout(); result.then( - function() { + 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')); } ); @@ -391,7 +391,7 @@ Runnable.prototype.run = function(fn) { } function callFnAsync(fn) { - var result = fn.call(ctx, function(err) { + var result = fn.call(ctx, function (err) { if (err instanceof Error || toString.call(err) === '[object Error]') { return done(err); } @@ -423,7 +423,7 @@ Runnable.prototype.run = function(fn) { * @returns {Error} a "timeout" error * @private */ -Runnable.prototype._timeoutError = function(ms) { +Runnable.prototype._timeoutError = function (ms) { let msg = `Timeout of ${ms}ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves.`; if (this.file) { msg += ' (' + this.file + ')'; @@ -463,7 +463,7 @@ var constants = utils.defineConstants( * @returns {*|Error} `value`, otherwise an `Error` * @private */ -Runnable.toValueOrError = function(value) { +Runnable.toValueOrError = function (value) { return ( value || createInvalidExceptionError( diff --git a/lib/runner.js b/lib/runner.js index 87f93c20b3..787f29e6e9 100644 --- a/lib/runner.js +++ b/lib/runner.js @@ -168,7 +168,7 @@ class Runner extends EventEmitter { * @type {Map>>} */ this._eventListeners = new Map(); - this.on(constants.EVENT_TEST_END, function(test) { + this.on(constants.EVENT_TEST_END, function (test) { if (test.type === 'test' && test.retriedTest() && test.parent) { var idx = test.parent.tests && test.parent.tests.indexOf(test.retriedTest()); @@ -176,7 +176,7 @@ class Runner extends EventEmitter { } self.checkGlobals(test); }); - this.on(constants.EVENT_HOOK_END, function(hook) { + this.on(constants.EVENT_HOOK_END, function (hook) { self.checkGlobals(hook); }); this._defaultGrep = /.*/; @@ -225,7 +225,7 @@ Runner.immediately = global.setImmediate || process.nextTick; * @param {string} fn - Listener function * @private */ -Runner.prototype._addEventListener = function(target, eventName, listener) { +Runner.prototype._addEventListener = function (target, eventName, listener) { debug( '_addEventListener(): adding for event %s; %d current listeners', eventName, @@ -235,10 +235,7 @@ Runner.prototype._addEventListener = function(target, eventName, listener) { if ( this._eventListeners.has(target) && this._eventListeners.get(target).has(eventName) && - this._eventListeners - .get(target) - .get(eventName) - .has(listener) + this._eventListeners.get(target).get(eventName).has(listener) ) { debug( 'warning: tried to attach duplicate event listener for %s', @@ -265,7 +262,7 @@ Runner.prototype._addEventListener = function(target, eventName, listener) { * @param {function} listener - Listener function * @private */ -Runner.prototype._removeEventListener = function(target, eventName, listener) { +Runner.prototype._removeEventListener = function (target, eventName, listener) { target.removeListener(eventName, listener); if (this._eventListeners.has(target)) { @@ -289,7 +286,7 @@ Runner.prototype._removeEventListener = function(target, eventName, listener) { * Removes all event handlers set during a run on this instance. * Remark: this does _not_ clean/dispose the tests or suites themselves. */ -Runner.prototype.dispose = function() { +Runner.prototype.dispose = function () { this.removeAllListeners(); this._eventListeners.forEach((targetListeners, target) => { targetListeners.forEach((targetEventListeners, eventName) => { @@ -311,7 +308,7 @@ Runner.prototype.dispose = function() { * @param {boolean} invert * @return {Runner} Runner instance. */ -Runner.prototype.grep = function(re, invert) { +Runner.prototype.grep = function (re, invert) { debug('grep(): setting to %s', re); this._grep = re; this._invert = invert; @@ -328,11 +325,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; @@ -351,7 +348,7 @@ Runner.prototype.grepTotal = function(suite) { * @return {Array} * @private */ -Runner.prototype.globalProps = function() { +Runner.prototype.globalProps = function () { var props = Object.keys(global); // non-enumerables @@ -373,7 +370,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; } @@ -387,7 +384,7 @@ Runner.prototype.globals = function(arr) { * * @private */ -Runner.prototype.checkGlobals = function(test) { +Runner.prototype.checkGlobals = function (test) { if (!this.checkLeaks) { return; } @@ -435,7 +432,7 @@ Runner.prototype.checkGlobals = function(test) { * @param {Error} err * @param {boolean} [force=false] - Whether to fail a pending test. */ -Runner.prototype.fail = function(test, err, force) { +Runner.prototype.fail = function (test, err, force) { force = force === true; if (test.isPending() && !force) { return; @@ -476,7 +473,7 @@ Runner.prototype.fail = function(test, err, force) { * @param {Function} fn */ -Runner.prototype.hook = function(name, fn) { +Runner.prototype.hook = function (name, fn) { if (this._opts.dryRun) return fn(); var suite = this.suite; @@ -505,7 +502,7 @@ Runner.prototype.hook = function(name, fn) { self.emit(constants.EVENT_HOOK_BEGIN, hook); if (!hook.listeners('error').length) { - self._addEventListener(hook, 'error', function(err) { + self._addEventListener(hook, 'error', function (err) { self.fail(hook, err); }); } @@ -530,10 +527,10 @@ Runner.prototype.hook = function(name, fn) { hook.pending = false; // activates hook for next test return fn(new Error('abort hookDown')); } else if (name === HOOK_TYPE_BEFORE_ALL) { - suite.tests.forEach(function(test) { + suite.tests.forEach(function (test) { test.pending = true; }); - suite.suites.forEach(function(suite) { + suite.suites.forEach(function (suite) { suite.pending = true; }); hooks = []; @@ -570,7 +567,7 @@ Runner.prototype.hook = function(name, fn) { } } - Runner.immediately(function() { + Runner.immediately(function () { next(0); }); }; @@ -584,7 +581,7 @@ 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; @@ -596,7 +593,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; @@ -617,7 +614,7 @@ Runner.prototype.hooks = function(name, suites, fn) { * @param {Function} fn * @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); }; @@ -629,7 +626,7 @@ Runner.prototype.hookUp = function(name, fn) { * @param {Function} fn * @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); }; @@ -641,7 +638,7 @@ Runner.prototype.hookDown = function(name, fn) { * @return {Array} * @private */ -Runner.prototype.parents = function() { +Runner.prototype.parents = function () { var suite = this.suite; var suites = []; while (suite.parent) { @@ -657,7 +654,7 @@ Runner.prototype.parents = function() { * @param {Function} fn * @private */ -Runner.prototype.runTest = function(fn) { +Runner.prototype.runTest = function (fn) { if (this._opts.dryRun) return fn(); var self = this; @@ -670,7 +667,7 @@ Runner.prototype.runTest = function(fn) { if (this.asyncOnly) { test.asyncOnly = true; } - this._addEventListener(test, 'error', function(err) { + this._addEventListener(test, 'error', function (err) { self.fail(test, err); }); if (this.allowUncaught) { @@ -691,7 +688,7 @@ 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; @@ -705,7 +702,7 @@ Runner.prototype.runTests = function(suite, fn) { self.suite = after ? errSuite.parent : errSuite; if (self.suite) { - self.hookUp(HOOK_TYPE_AFTER_EACH, function(err2, errSuite2) { + self.hookUp(HOOK_TYPE_AFTER_EACH, function (err2, errSuite2) { self.suite = orig; // some hooks may fail even now if (err2) { @@ -779,7 +776,7 @@ Runner.prototype.runTests = function(suite, fn) { // execute test and hook(s) self.emit(constants.EVENT_TEST_BEGIN, (self.test = test)); - self.hookDown(HOOK_TYPE_BEFORE_EACH, function(err, errSuite) { + self.hookDown(HOOK_TYPE_BEFORE_EACH, function (err, errSuite) { // conditional skip within beforeEach if (test.isPending()) { if (self.forbidPending) { @@ -792,7 +789,7 @@ Runner.prototype.runTests = function(suite, fn) { // skip inner afterEach hooks below errSuite level var origSuite = self.suite; self.suite = errSuite || self.suite; - return self.hookUp(HOOK_TYPE_AFTER_EACH, function(e, eSuite) { + return self.hookUp(HOOK_TYPE_AFTER_EACH, function (e, eSuite) { self.suite = origSuite; next(e, eSuite); }); @@ -801,7 +798,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; // conditional skip within it if (test.pending) { @@ -852,7 +849,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); @@ -892,7 +889,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 { @@ -907,7 +904,7 @@ Runner.prototype.runSuite = function(suite, fn) { // remove reference to test delete self.test; - self.hook(HOOK_TYPE_AFTER_ALL, function() { + self.hook(HOOK_TYPE_AFTER_ALL, function () { self.emit(constants.EVENT_SUITE_END, suite); fn(errSuite); }); @@ -915,7 +912,7 @@ Runner.prototype.runSuite = function(suite, fn) { this.nextSuite = next; - this.hook(HOOK_TYPE_BEFORE_ALL, function(err) { + this.hook(HOOK_TYPE_BEFORE_ALL, function (err) { if (err) { return done(); } @@ -939,7 +936,7 @@ Runner.prototype.runSuite = function(suite, fn) { * @param {Error} err - Some uncaught error * @private */ -Runner.prototype._uncaught = function(err) { +Runner.prototype._uncaught = function (err) { // this is defensive to prevent future developers from mis-calling this function. // it's more likely that it'd be called with the incorrect context--say, the global // `process` object--than it would to be called with a context that is not a "subclass" @@ -1037,12 +1034,12 @@ Runner.prototype._uncaught = function(err) { * @param {{files: string[], options: Options}} [opts] - For subclasses * @returns {Runner} Runner instance. */ -Runner.prototype.run = function(fn, opts = {}) { +Runner.prototype.run = function (fn, opts = {}) { var rootSuite = this.suite; var options = opts.options || {}; debug('run(): got options: %O', options); - fn = fn || function() {}; + fn = fn || function () {}; const end = () => { if (!this.total && this._opts.failZero) this.failures = 1; @@ -1083,7 +1080,7 @@ Runner.prototype.run = function(fn, opts = {}) { } // callback - this.on(constants.EVENT_RUN_END, function() { + this.on(constants.EVENT_RUN_END, function () { this.state = constants.STATE_STOPPED; debug('run(): emitted %s', constants.EVENT_RUN_END); fn(this.failures); @@ -1130,7 +1127,7 @@ Runner.prototype.run = function(fn, opts = {}) { * } * } */ -Runner.prototype.linkPartialObjects = function(value) { +Runner.prototype.linkPartialObjects = function (value) { return this; }; @@ -1155,7 +1152,7 @@ Runner.prototype.runAsync = async function runAsync(opts = {}) { * @public * @return {Runner} Runner instance. */ -Runner.prototype.abort = function() { +Runner.prototype.abort = function () { debug('abort(): aborting'); this._abort = true; @@ -1183,7 +1180,7 @@ Runner.prototype.isParallelMode = function isParallelMode() { * @chainable * @abstract */ -Runner.prototype.workerReporter = function() { +Runner.prototype.workerReporter = function () { throw createUnsupportedError('workerReporter() not supported in serial mode'); }; @@ -1196,7 +1193,7 @@ Runner.prototype.workerReporter = function() { * @return {Array} */ function filterLeaks(ok, globals) { - return globals.filter(function(key) { + return globals.filter(function (key) { // Firefox and Chrome exposes iframes as index inside the window object if (/^\d+/.test(key)) { return false; @@ -1220,7 +1217,7 @@ function filterLeaks(ok, globals) { return false; } - var matched = ok.filter(function(ok) { + var matched = ok.filter(function (ok) { if (~ok.indexOf('*')) { return key.indexOf(ok.split('*')[0]) === 0; } diff --git a/lib/stats-collector.js b/lib/stats-collector.js index 938778fb0e..738fd5d724 100644 --- a/lib/stats-collector.js +++ b/lib/stats-collector.js @@ -56,25 +56,25 @@ function createStatsCollector(runner) { runner.stats = stats; - runner.once(EVENT_RUN_BEGIN, function() { + runner.once(EVENT_RUN_BEGIN, function () { stats.start = new Date(); }); - runner.on(EVENT_SUITE_BEGIN, function(suite) { + runner.on(EVENT_SUITE_BEGIN, function (suite) { suite.root || stats.suites++; }); - runner.on(EVENT_TEST_PASS, function() { + runner.on(EVENT_TEST_PASS, function () { stats.passes++; }); - runner.on(EVENT_TEST_FAIL, function() { + runner.on(EVENT_TEST_FAIL, function () { stats.failures++; }); - runner.on(EVENT_TEST_PENDING, function() { + runner.on(EVENT_TEST_PENDING, function () { stats.pending++; }); - runner.on(EVENT_TEST_END, function() { + runner.on(EVENT_TEST_END, function () { stats.tests++; }); - runner.once(EVENT_RUN_END, function() { + runner.once(EVENT_RUN_END, function () { stats.end = new Date(); stats.duration = stats.end - stats.start; }); diff --git a/lib/suite.js b/lib/suite.js index 7fce325f25..43cb7556e1 100644 --- a/lib/suite.js +++ b/lib/suite.js @@ -35,7 +35,7 @@ exports = module.exports = Suite; * @param {string} title - Title * @return {Suite} */ -Suite.create = function(parent, title) { +Suite.create = function (parent, title) { var suite = new Suite(title, parent.ctx); suite.parent = parent; title = suite.fullTitle(); @@ -101,7 +101,7 @@ inherits(Suite, EventEmitter); /** * Resets the state initially or for a next run. */ -Suite.prototype.reset = function() { +Suite.prototype.reset = function () { this.delayed = false; function doReset(thingToReset) { thingToReset.reset(); @@ -120,7 +120,7 @@ Suite.prototype.reset = function() { * @private * @return {Suite} */ -Suite.prototype.clone = function() { +Suite.prototype.clone = function () { var suite = new Suite(this.title); debug('clone'); suite.ctx = this.ctx; @@ -140,7 +140,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; } @@ -165,7 +165,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; } @@ -181,7 +181,7 @@ Suite.prototype.retries = function(n) { * @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; } @@ -200,7 +200,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; } @@ -214,7 +214,7 @@ Suite.prototype.bail = function(bail) { * * @private */ -Suite.prototype.isPending = function() { +Suite.prototype.isPending = function () { return this.pending || (this.parent && this.parent.isPending()); }; @@ -225,7 +225,7 @@ Suite.prototype.isPending = function() { * @param {Function} fn - Hook callback * @returns {Hook} A new hook */ -Suite.prototype._createHook = function(title, fn) { +Suite.prototype._createHook = function (title, fn) { var hook = new Hook(title, fn); hook.parent = this; hook.timeout(this.timeout()); @@ -244,7 +244,7 @@ Suite.prototype._createHook = function(title, fn) { * @param {Function} fn * @return {Suite} for chaining */ -Suite.prototype.beforeAll = function(title, fn) { +Suite.prototype.beforeAll = function (title, fn) { if (this.isPending()) { return this; } @@ -268,7 +268,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; } @@ -292,7 +292,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; } @@ -316,7 +316,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; } @@ -339,7 +339,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.root = false; suite.timeout(this.timeout()); @@ -358,7 +358,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()); @@ -377,7 +377,7 @@ Suite.prototype.addTest = function(test) { * @public * @return {string} */ -Suite.prototype.fullTitle = function() { +Suite.prototype.fullTitle = function () { return this.titlePath().join(' '); }; @@ -389,7 +389,7 @@ Suite.prototype.fullTitle = function() { * @public * @return {string} */ -Suite.prototype.titlePath = function() { +Suite.prototype.titlePath = function () { var result = []; if (this.parent) { result = result.concat(this.parent.titlePath()); @@ -407,9 +407,9 @@ Suite.prototype.titlePath = function() { * @public * @return {number} */ -Suite.prototype.total = function() { +Suite.prototype.total = function () { return ( - this.suites.reduce(function(sum, suite) { + this.suites.reduce(function (sum, suite) { return sum + suite.total(); }, 0) + this.tests.length ); @@ -423,9 +423,9 @@ Suite.prototype.total = function() { * @param {Function} fn * @return {Suite} */ -Suite.prototype.eachTest = function(fn) { +Suite.prototype.eachTest = function (fn) { this.tests.forEach(fn); - this.suites.forEach(function(suite) { + this.suites.forEach(function (suite) { suite.eachTest(fn); }); return this; @@ -451,7 +451,7 @@ Suite.prototype.hasOnly = function hasOnly() { return ( this._onlyTests.length > 0 || this._onlySuites.length > 0 || - this.suites.some(function(suite) { + this.suites.some(function (suite) { return suite.hasOnly(); }) ); @@ -471,7 +471,7 @@ Suite.prototype.filterOnly = function filterOnly() { } else { // Otherwise, do not run any of the tests in this suite. this.tests = []; - this._onlySuites.forEach(function(onlySuite) { + this._onlySuites.forEach(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 (onlySuite.hasOnly()) { @@ -480,7 +480,7 @@ Suite.prototype.filterOnly = function filterOnly() { }); // Run the `only` suites, as well as any other suites that have `only` tests/suites as descendants. var onlySuites = this._onlySuites; - this.suites = this.suites.filter(function(childSuite) { + this.suites = this.suites.filter(function (childSuite) { return onlySuites.indexOf(childSuite) !== -1 || childSuite.filterOnly(); }); } @@ -494,7 +494,7 @@ Suite.prototype.filterOnly = function filterOnly() { * @private * @param {Suite} suite */ -Suite.prototype.appendOnlySuite = function(suite) { +Suite.prototype.appendOnlySuite = function (suite) { this._onlySuites.push(suite); }; @@ -503,7 +503,7 @@ Suite.prototype.appendOnlySuite = function(suite) { * * @private */ -Suite.prototype.markOnly = function() { +Suite.prototype.markOnly = function () { this.parent && this.parent.appendOnlySuite(this); }; @@ -513,7 +513,7 @@ Suite.prototype.markOnly = function() { * @private * @param {Test} test */ -Suite.prototype.appendOnlyTest = function(test) { +Suite.prototype.appendOnlyTest = function (test) { this._onlyTests.push(test); }; @@ -528,8 +528,8 @@ Suite.prototype.getHooks = function getHooks(name) { /** * cleans all references from this suite and all child suites. */ -Suite.prototype.dispose = function() { - this.suites.forEach(function(suite) { +Suite.prototype.dispose = function () { + this.suites.forEach(function (suite) { suite.dispose(); }); this.cleanReferences(); diff --git a/lib/test.js b/lib/test.js index fc5f8727e7..0b8fe18be7 100644 --- a/lib/test.js +++ b/lib/test.js @@ -41,7 +41,7 @@ utils.inherits(Test, Runnable); /** * Resets the state initially or for a next run. */ -Test.prototype.reset = function() { +Test.prototype.reset = function () { Runnable.prototype.reset.call(this); this.pending = !this.fn; delete this.state; @@ -52,7 +52,7 @@ Test.prototype.reset = function() { * * @private */ -Test.prototype.retriedTest = function(n) { +Test.prototype.retriedTest = function (n) { if (!arguments.length) { return this._retriedTest; } @@ -64,11 +64,11 @@ Test.prototype.retriedTest = function(n) { * * @private */ -Test.prototype.markOnly = function() { +Test.prototype.markOnly = function () { this.parent.appendOnlyTest(this); }; -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.js index e3d5d73a58..9db34cb1ad 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -34,7 +34,7 @@ exports.inherits = util.inherits; * @param {string} html * @return {string} */ -exports.escape = function(html) { +exports.escape = function (html) { return he.encode(String(html), {useNamedReferences: false}); }; @@ -45,7 +45,7 @@ exports.escape = function(html) { * @param {Object} obj * @return {boolean} */ -exports.isString = function(obj) { +exports.isString = function (obj) { return typeof obj === 'string'; }; @@ -56,7 +56,7 @@ exports.isString = function(obj) { * @param {string} str * @return {string} */ -exports.slug = function(str) { +exports.slug = function (str) { return str .toLowerCase() .replace(/\s+/g, '-') @@ -70,7 +70,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/, '') @@ -212,7 +212,7 @@ exports.type = function type(value) { * @param {*} value * @return {string} */ -exports.stringify = function(value) { +exports.stringify = function (value) { var typeHint = canonicalType(value); if (!~['object', 'array', 'function'].indexOf(typeHint)) { @@ -228,7 +228,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 = value.split('').reduce(function(acc, char, idx) { + value = value.split('').reduce(function (acc, char, idx) { acc[idx] = char; return acc; }, {}); @@ -383,8 +383,8 @@ exports.canonicalize = function canonicalize(value, stack, typeHint) { canonicalizedObj = value; break; case 'array': - withStack(value, function() { - canonicalizedObj = value.map(function(item) { + withStack(value, function () { + canonicalizedObj = value.map(function (item) { return exports.canonicalize(item, stack); }); }); @@ -403,10 +403,10 @@ exports.canonicalize = function canonicalize(value, stack, typeHint) { /* falls through */ case 'object': canonicalizedObj = canonicalizedObj || {}; - withStack(value, function() { + withStack(value, function () { Object.keys(value) .sort() - .forEach(function(key) { + .forEach(function (key) { canonicalizedObj[key] = exports.canonicalize(value[key], stack); }); }); @@ -434,7 +434,7 @@ exports.canonicalize = function canonicalize(value, stack, typeHint) { * (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; @@ -442,9 +442,8 @@ exports.stackTraceFilter = function() { if (is.node) { cwd = exports.cwd() + slash; } else { - cwd = (typeof location === 'undefined' - ? window.location - : location + cwd = ( + typeof location === 'undefined' ? window.location : location ).href.replace(/\/[^/]*$/, '/'); slash = '/'; } @@ -468,10 +467,10 @@ exports.stackTraceFilter = function() { ); } - return function(stack) { + return function (stack) { stack = stack.split('\n'); - stack = stack.reduce(function(list, line) { + stack = stack.reduce(function (list, line) { if (isMochaInternal(line)) { return list; } @@ -522,7 +521,7 @@ exports.clamp = function clamp(value, range) { * It's a noop. * @public */ -exports.noop = function() {}; +exports.noop = function () {}; /** * Creates a map-like object. @@ -539,7 +538,7 @@ exports.noop = function() {}; * @param {...*} [obj] - Arguments to `Object.assign()`. * @returns {Object} An object with no prototype, having `...obj` properties */ -exports.createMap = function(obj) { +exports.createMap = function (obj) { return Object.assign.apply( null, [Object.create(null)].concat(Array.prototype.slice.call(arguments)) @@ -558,7 +557,7 @@ exports.createMap = function(obj) { * @returns {Object} A frozen object with no prototype, having `...obj` properties * @throws {TypeError} if argument is not a non-empty object. */ -exports.defineConstants = function(obj) { +exports.defineConstants = function (obj) { if (canonicalType(obj) !== 'object' || !Object.keys(obj).length) { throw new TypeError('Invalid argument; expected a non-empty object'); } diff --git a/package-lock.json b/package-lock.json index 9385b5afc8..6bab24e148 100644 --- a/package-lock.json +++ b/package-lock.json @@ -91,7 +91,7 @@ "nps": "^5.10.0", "nyc": "^15.1.0", "pidtree": "^0.5.0", - "prettier": "^1.19.1", + "prettier": "^2.4.1", "regenerator-runtime": "0.13.7", "remark": "^14.0.1", "remark-github": "^11.1.1", @@ -2579,9 +2579,9 @@ "dev": true }, "node_modules/@types/node": { - "version": "16.11.4", - "resolved": "https://registry.npmjs.org/@types/node/-/node-16.11.4.tgz", - "integrity": "sha512-TMgXmy0v2xWyuCSCJM6NCna2snndD8yvQF67J29ipdzMcsPa9u+o0tjF5+EQNdhcuZplYuouYqpc4zcd5I6amQ==", + "version": "16.11.5", + "resolved": "https://registry.npmjs.org/@types/node/-/node-16.11.5.tgz", + "integrity": "sha512-NyUV2DGcqYIx9op++MG2+Z4Nhw1tPhi0Wfs81TgncuX1aJC4zf2fgCJlJhl4BW9bCSS04e34VkqmOS96w0XQdg==", "dev": true }, "node_modules/@types/normalize-package-data": { @@ -6626,9 +6626,9 @@ } }, "node_modules/core-js": { - "version": "3.18.3", - "resolved": "https://registry.npmjs.org/core-js/-/core-js-3.18.3.tgz", - "integrity": "sha512-tReEhtMReZaPFVw7dajMx0vlsz3oOb8ajgPoHVYGxr8ErnZ6PcYEvvmjGmXlfpnxpkYSdOQttjB+MvVbCGfvLw==", + "version": "3.19.0", + "resolved": "https://registry.npmjs.org/core-js/-/core-js-3.19.0.tgz", + "integrity": "sha512-L1TpFRWXZ76vH1yLM+z6KssLZrP8Z6GxxW4auoCj+XiViOzNPJCAuTIkn03BGdFe6Z5clX5t64wRIRypsZQrUg==", "dev": true, "hasInstallScript": true, "funding": { @@ -6637,12 +6637,12 @@ } }, "node_modules/core-js-compat": { - "version": "3.18.3", - "resolved": "https://registry.npmjs.org/core-js-compat/-/core-js-compat-3.18.3.tgz", - "integrity": "sha512-4zP6/y0a2RTHN5bRGT7PTq9lVt3WzvffTNjqnTKsXhkAYNDTkdCLOIfAdOLcQ/7TDdyRj3c+NeHe1NmF1eDScw==", + "version": "3.19.0", + "resolved": "https://registry.npmjs.org/core-js-compat/-/core-js-compat-3.19.0.tgz", + "integrity": "sha512-R09rKZ56ccGBebjTLZHvzDxhz93YPT37gBm6qUhnwj3Kt7aCjjZWD1injyNbyeFHxNKfeZBSyds6O9n3MKq1sw==", "dev": true, "dependencies": { - "browserslist": "^4.17.3", + "browserslist": "^4.17.5", "semver": "7.0.0" }, "funding": { @@ -8715,25 +8715,6 @@ "node": ">=4" } }, - "node_modules/eslint-plugin-es": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/eslint-plugin-es/-/eslint-plugin-es-3.0.1.tgz", - "integrity": "sha512-GUmAsJaN4Fc7Gbtl8uOBlayo2DqhwWvEzykMHSCZHU3XdJ+NSzzZcVhXh3VxX5icqQ+oQdIEawXX8xkR3mIFmQ==", - "dev": true, - "dependencies": { - "eslint-utils": "^2.0.0", - "regexpp": "^3.0.0" - }, - "engines": { - "node": ">=8.10.0" - }, - "funding": { - "url": "https://github.com/sponsors/mysticatea" - }, - "peerDependencies": { - "eslint": ">=4.19.1" - } - }, "node_modules/eslint-plugin-import": { "version": "2.25.2", "resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.25.2.tgz", @@ -8808,6 +8789,25 @@ "eslint": ">=5.16.0" } }, + "node_modules/eslint-plugin-node/node_modules/eslint-plugin-es": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/eslint-plugin-es/-/eslint-plugin-es-3.0.1.tgz", + "integrity": "sha512-GUmAsJaN4Fc7Gbtl8uOBlayo2DqhwWvEzykMHSCZHU3XdJ+NSzzZcVhXh3VxX5icqQ+oQdIEawXX8xkR3mIFmQ==", + "dev": true, + "dependencies": { + "eslint-utils": "^2.0.0", + "regexpp": "^3.0.0" + }, + "engines": { + "node": ">=8.10.0" + }, + "funding": { + "url": "https://github.com/sponsors/mysticatea" + }, + "peerDependencies": { + "eslint": ">=4.19.1" + } + }, "node_modules/eslint-plugin-node/node_modules/ignore": { "version": "5.1.8", "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.1.8.tgz", @@ -9099,9 +9099,9 @@ } }, "node_modules/estraverse": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.2.0.tgz", - "integrity": "sha512-BxbNGGNm0RyRYvUdHpIwv9IWzeM9XClbOxwoATuFdOE7ZE6wHL+HQ5T8hoPM+zHvmKzzsEqhgy0GrQ5X13afiQ==", + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz", + "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==", "dev": true, "engines": { "node": ">=4.0" @@ -13000,9 +13000,9 @@ "dev": true }, "node_modules/karma": { - "version": "6.3.5", - "resolved": "https://registry.npmjs.org/karma/-/karma-6.3.5.tgz", - "integrity": "sha512-uAwOPXtfEdIHIZdK7QcnKEv0BK/bg+AZikZ7TK1ZLk3apW/wNH74rbdamJby1CVVYw3I9PXxqeEo78OaiHeErA==", + "version": "6.3.6", + "resolved": "https://registry.npmjs.org/karma/-/karma-6.3.6.tgz", + "integrity": "sha512-xsiu3D6AjCv6Uq0YKXJgC6TvXX2WloQ5+XtHXmC1lwiLVG617DDV3W2DdM4BxCMKHlmz6l3qESZHFQGHAKvrew==", "dev": true, "dependencies": { "body-parser": "^1.19.0", @@ -13026,7 +13026,7 @@ "socket.io": "^4.2.0", "source-map": "^0.6.1", "tmp": "^0.2.1", - "ua-parser-js": "^0.7.28", + "ua-parser-js": "^0.7.30", "yargs": "^16.1.1" }, "bin": { @@ -18861,15 +18861,15 @@ } }, "node_modules/prettier": { - "version": "1.19.1", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-1.19.1.tgz", - "integrity": "sha512-s7PoyDv/II1ObgQunCbB9PdLmUcBZcnWOcxDh7O0N/UwDEsHyqkW+Qh28jW+mVuCdx7gLB0BotYI1Y6uI9iyew==", + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.4.1.tgz", + "integrity": "sha512-9fbDAXSBcc6Bs1mZrDYb3XKzDLm4EXXL9sC1LqKP5rZkT6KRr/rf9amVUcODVXgguK/isJz0d0hP72WeaKWsvA==", "dev": true, "bin": { "prettier": "bin-prettier.js" }, "engines": { - "node": ">=4" + "node": ">=10.13.0" } }, "node_modules/prettier-linter-helpers": { @@ -20449,9 +20449,9 @@ } }, "node_modules/rollup": { - "version": "2.58.0", - "resolved": "https://registry.npmjs.org/rollup/-/rollup-2.58.0.tgz", - "integrity": "sha512-NOXpusKnaRpbS7ZVSzcEXqxcLDOagN6iFS8p45RkoiMqPHDLwJm758UF05KlMoCRbLBTZsPOIa887gZJ1AiXvw==", + "version": "2.58.3", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-2.58.3.tgz", + "integrity": "sha512-ei27MSw1KhRur4p87Q0/Va2NAYqMXOX++FNEumMBcdreIRLURKy+cE2wcDJKBn0nfmhP2ZGrJkP1XPO+G8FJQw==", "dev": true, "bin": { "rollup": "dist/bin/rollup" @@ -24607,9 +24607,9 @@ } }, "node_modules/webpack": { - "version": "5.59.1", - "resolved": "https://registry.npmjs.org/webpack/-/webpack-5.59.1.tgz", - "integrity": "sha512-I01IQV9K96FlpXX3V0L4nvd7gb0r7thfuu1IfT2P4uOHOA77nKARAKDYGe/tScSHKnffNIyQhLC8kRXzY4KEHQ==", + "version": "5.60.0", + "resolved": "https://registry.npmjs.org/webpack/-/webpack-5.60.0.tgz", + "integrity": "sha512-OL5GDYi2dKxnwJPSOg2tODgzDxAffN0osgWkZaBo/l3ikCxDFP+tuJT3uF7GyBE3SDBpKML/+a8EobyWAQO3DQ==", "dev": true, "dependencies": { "@types/eslint-scope": "^3.7.0", @@ -27234,9 +27234,9 @@ "dev": true }, "@types/node": { - "version": "16.11.4", - "resolved": "https://registry.npmjs.org/@types/node/-/node-16.11.4.tgz", - "integrity": "sha512-TMgXmy0v2xWyuCSCJM6NCna2snndD8yvQF67J29ipdzMcsPa9u+o0tjF5+EQNdhcuZplYuouYqpc4zcd5I6amQ==", + "version": "16.11.5", + "resolved": "https://registry.npmjs.org/@types/node/-/node-16.11.5.tgz", + "integrity": "sha512-NyUV2DGcqYIx9op++MG2+Z4Nhw1tPhi0Wfs81TgncuX1aJC4zf2fgCJlJhl4BW9bCSS04e34VkqmOS96w0XQdg==", "dev": true }, "@types/normalize-package-data": { @@ -27517,7 +27517,8 @@ "version": "1.1.0", "resolved": "https://registry.npmjs.org/@webpack-cli/configtest/-/configtest-1.1.0.tgz", "integrity": "sha512-ttOkEkoalEHa7RaFYpM0ErK1xc4twg3Am9hfHhL7MVqlHebnkYd2wuI/ZqTDj0cVzZho6PdinY0phFZV3O0Mzg==", - "dev": true + "dev": true, + "requires": {} }, "@webpack-cli/info": { "version": "1.4.0", @@ -27532,7 +27533,8 @@ "version": "1.6.0", "resolved": "https://registry.npmjs.org/@webpack-cli/serve/-/serve-1.6.0.tgz", "integrity": "sha512-ZkVeqEmRpBV2GHvjjUZqEai2PpUbuq8Bqd//vEYsp63J8WyexI8ppCqVS3Zs0QADf6aWuPdU+0XsPI647PVlQA==", - "dev": true + "dev": true, + "requires": {} }, "@xtuc/ieee754": { "version": "1.2.0", @@ -27602,13 +27604,15 @@ "version": "1.8.0", "resolved": "https://registry.npmjs.org/acorn-import-assertions/-/acorn-import-assertions-1.8.0.tgz", "integrity": "sha512-m7VZ3jwz4eK6A4Vtt8Ew1/mNbP24u0FhdyfA7fSvnJR6LMdfOYnmuIrrJAgrYfYJ10F/otaHTtrtrtmHdMNzEw==", - "dev": true + "dev": true, + "requires": {} }, "acorn-jsx": { "version": "5.3.2", "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.2.tgz", "integrity": "sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==", - "dev": true + "dev": true, + "requires": {} }, "acorn-node": { "version": "1.8.2", @@ -27676,7 +27680,8 @@ "version": "3.5.2", "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-3.5.2.tgz", "integrity": "sha512-5p6WTN0DdTGVQk6VjcEju19IgaHudalcfabD7yhDGeA6bcQnmL+CpveLJq/3hvfwd1aof6L386Ougkx6RfyMIQ==", - "dev": true + "dev": true, + "requires": {} }, "alphanum-sort": { "version": "1.0.2", @@ -28291,7 +28296,8 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/assetgraph-plugin-sitemap/-/assetgraph-plugin-sitemap-1.0.0.tgz", "integrity": "sha512-NaGLdrFemTLss6PxW0f1JVqcV8n1jjERwyBTyz49PZCKkARkZTSOvnoM55wxTXlPkqsLZq7K2/lO56pmYbbCOA==", - "dev": true + "dev": true, + "requires": {} }, "assetgraph-sprite": { "version": "3.2.1", @@ -30622,18 +30628,18 @@ "dev": true }, "core-js": { - "version": "3.18.3", - "resolved": "https://registry.npmjs.org/core-js/-/core-js-3.18.3.tgz", - "integrity": "sha512-tReEhtMReZaPFVw7dajMx0vlsz3oOb8ajgPoHVYGxr8ErnZ6PcYEvvmjGmXlfpnxpkYSdOQttjB+MvVbCGfvLw==", + "version": "3.19.0", + "resolved": "https://registry.npmjs.org/core-js/-/core-js-3.19.0.tgz", + "integrity": "sha512-L1TpFRWXZ76vH1yLM+z6KssLZrP8Z6GxxW4auoCj+XiViOzNPJCAuTIkn03BGdFe6Z5clX5t64wRIRypsZQrUg==", "dev": true }, "core-js-compat": { - "version": "3.18.3", - "resolved": "https://registry.npmjs.org/core-js-compat/-/core-js-compat-3.18.3.tgz", - "integrity": "sha512-4zP6/y0a2RTHN5bRGT7PTq9lVt3WzvffTNjqnTKsXhkAYNDTkdCLOIfAdOLcQ/7TDdyRj3c+NeHe1NmF1eDScw==", + "version": "3.19.0", + "resolved": "https://registry.npmjs.org/core-js-compat/-/core-js-compat-3.19.0.tgz", + "integrity": "sha512-R09rKZ56ccGBebjTLZHvzDxhz93YPT37gBm6qUhnwj3Kt7aCjjZWD1injyNbyeFHxNKfeZBSyds6O9n3MKq1sw==", "dev": true, "requires": { - "browserslist": "^4.17.3", + "browserslist": "^4.17.5", "semver": "7.0.0" }, "dependencies": { @@ -31934,7 +31940,8 @@ "version": "7.4.6", "resolved": "https://registry.npmjs.org/ws/-/ws-7.4.6.tgz", "integrity": "sha512-YmhHDO4MzaDLB+M9ym/mDA5z0naX8j7SIlT8f8z+I0VtzsRbekxEutHSme7NPS2qE8StCYQNUnfWdXta/Yu85A==", - "dev": true + "dev": true, + "requires": {} } } }, @@ -31976,7 +31983,8 @@ "version": "7.4.6", "resolved": "https://registry.npmjs.org/ws/-/ws-7.4.6.tgz", "integrity": "sha512-YmhHDO4MzaDLB+M9ym/mDA5z0naX8j7SIlT8f8z+I0VtzsRbekxEutHSme7NPS2qE8StCYQNUnfWdXta/Yu85A==", - "dev": true + "dev": true, + "requires": {} } } }, @@ -32286,19 +32294,22 @@ "version": "8.3.0", "resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-8.3.0.tgz", "integrity": "sha512-BgZuLUSeKzvlL/VUjx/Yb787VQ26RU3gGjA3iiFvdsp/2bMfVIWUVP7tjxtjS0e+HP409cPlPvNkQloz8C91ew==", - "dev": true + "dev": true, + "requires": {} }, "eslint-config-semistandard": { "version": "16.0.0", "resolved": "https://registry.npmjs.org/eslint-config-semistandard/-/eslint-config-semistandard-16.0.0.tgz", "integrity": "sha512-oD8QOo4mSInRJhQb3Zi6L8HebwZaB6SI3A+NNrPdVN0nN1K45L5pXK3joY+ksWDlT3ew/M+fJk2tuMCjIpjRzQ==", - "dev": true + "dev": true, + "requires": {} }, "eslint-config-standard": { "version": "16.0.3", "resolved": "https://registry.npmjs.org/eslint-config-standard/-/eslint-config-standard-16.0.3.tgz", "integrity": "sha512-x4fmJL5hGqNJKGHSjnLdgA6U6h1YW/G2dW9fA+cyVur4SK6lyue8+UgNKWlZtUDTXvgKDD/Oa3GQjmB5kjtVvg==", - "dev": true + "dev": true, + "requires": {} }, "eslint-import-resolver-node": { "version": "0.3.6", @@ -32392,16 +32403,6 @@ } } }, - "eslint-plugin-es": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/eslint-plugin-es/-/eslint-plugin-es-3.0.1.tgz", - "integrity": "sha512-GUmAsJaN4Fc7Gbtl8uOBlayo2DqhwWvEzykMHSCZHU3XdJ+NSzzZcVhXh3VxX5icqQ+oQdIEawXX8xkR3mIFmQ==", - "dev": true, - "requires": { - "eslint-utils": "^2.0.0", - "regexpp": "^3.0.0" - } - }, "eslint-plugin-import": { "version": "2.25.2", "resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.25.2.tgz", @@ -32463,6 +32464,16 @@ "semver": "^6.1.0" }, "dependencies": { + "eslint-plugin-es": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/eslint-plugin-es/-/eslint-plugin-es-3.0.1.tgz", + "integrity": "sha512-GUmAsJaN4Fc7Gbtl8uOBlayo2DqhwWvEzykMHSCZHU3XdJ+NSzzZcVhXh3VxX5icqQ+oQdIEawXX8xkR3mIFmQ==", + "dev": true, + "requires": { + "eslint-utils": "^2.0.0", + "regexpp": "^3.0.0" + } + }, "ignore": { "version": "5.1.8", "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.1.8.tgz", @@ -32490,7 +32501,8 @@ "version": "5.1.1", "resolved": "https://registry.npmjs.org/eslint-plugin-promise/-/eslint-plugin-promise-5.1.1.tgz", "integrity": "sha512-XgdcdyNzHfmlQyweOPTxmc7pIsS6dE4MvwhXWMQ2Dxs1XAL2GJDilUsjWen6TWik0aSI+zD/PqocZBblcm9rdA==", - "dev": true + "dev": true, + "requires": {} }, "eslint-scope": { "version": "5.1.1", @@ -32589,16 +32601,17 @@ } }, "estraverse": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.2.0.tgz", - "integrity": "sha512-BxbNGGNm0RyRYvUdHpIwv9IWzeM9XClbOxwoATuFdOE7ZE6wHL+HQ5T8hoPM+zHvmKzzsEqhgy0GrQ5X13afiQ==", + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz", + "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==", "dev": true }, "estraverse-fb": { "version": "1.3.2", "resolved": "https://registry.npmjs.org/estraverse-fb/-/estraverse-fb-1.3.2.tgz", "integrity": "sha1-0yOky15awzHOoDNBOpJT4WQ+B8Q=", - "dev": true + "dev": true, + "requires": {} }, "estree-walker": { "version": "1.0.1", @@ -32873,7 +32886,8 @@ "version": "3.0.0", "resolved": "https://registry.npmjs.org/fail-on-errors-webpack-plugin/-/fail-on-errors-webpack-plugin-3.0.0.tgz", "integrity": "sha512-U0WqfpDZV4HI9ueb7sWmZzEr+yjo0R3JCCw6nIfzJU6gnN1rU1k+1XPea7LqcZTOwmfbf4DuhMswWl1quxj7Xw==", - "dev": true + "dev": true, + "requires": {} }, "fast-deep-equal": { "version": "3.1.3", @@ -35593,9 +35607,9 @@ "dev": true }, "karma": { - "version": "6.3.5", - "resolved": "https://registry.npmjs.org/karma/-/karma-6.3.5.tgz", - "integrity": "sha512-uAwOPXtfEdIHIZdK7QcnKEv0BK/bg+AZikZ7TK1ZLk3apW/wNH74rbdamJby1CVVYw3I9PXxqeEo78OaiHeErA==", + "version": "6.3.6", + "resolved": "https://registry.npmjs.org/karma/-/karma-6.3.6.tgz", + "integrity": "sha512-xsiu3D6AjCv6Uq0YKXJgC6TvXX2WloQ5+XtHXmC1lwiLVG617DDV3W2DdM4BxCMKHlmz6l3qESZHFQGHAKvrew==", "dev": true, "requires": { "body-parser": "^1.19.0", @@ -35619,7 +35633,7 @@ "socket.io": "^4.2.0", "source-map": "^0.6.1", "tmp": "^0.2.1", - "ua-parser-js": "^0.7.28", + "ua-parser-js": "^0.7.30", "yargs": "^16.1.1" }, "dependencies": { @@ -35758,7 +35772,8 @@ "version": "8.2.3", "resolved": "https://registry.npmjs.org/ws/-/ws-8.2.3.tgz", "integrity": "sha512-wBuoj1BDpC6ZQ1B7DWQBYVLphPWkm8i9Y0/3YdHjHKHiohOJ1ws+3OccDWtH+PoC9DZD5WOTrJvNbWvjS6JWaA==", - "dev": true + "dev": true, + "requires": {} } } }, @@ -35888,7 +35903,8 @@ "version": "1.1.0", "resolved": "https://registry.npmjs.org/karma-requirejs/-/karma-requirejs-1.1.0.tgz", "integrity": "sha1-/driy4fX68FvsCIok1ZNf+5Xh5g=", - "dev": true + "dev": true, + "requires": {} }, "karma-sauce-launcher": { "version": "4.3.6", @@ -36720,13 +36736,15 @@ "version": "5.3.0", "resolved": "https://registry.npmjs.org/markdown-it-anchor/-/markdown-it-anchor-5.3.0.tgz", "integrity": "sha512-/V1MnLL/rgJ3jkMWo84UR+K+jF1cxNG1a+KwqeXqTIJ+jtA8aWSHuigx8lTzauiIjBDbwF3NcWQMotd0Dm39jA==", - "dev": true + "dev": true, + "requires": {} }, "markdown-it-attrs": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/markdown-it-attrs/-/markdown-it-attrs-3.0.3.tgz", "integrity": "sha512-cLnICU2t61skNCr4Wih/sdza+UbQcqJGZwvqAypnbWA284nzDm+Gpc90iaRk/JjsIy4emag5v3s0rXFhFBWhCA==", - "dev": true + "dev": true, + "requires": {} }, "markdown-it-emoji": { "version": "1.4.0", @@ -40244,9 +40262,9 @@ "dev": true }, "prettier": { - "version": "1.19.1", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-1.19.1.tgz", - "integrity": "sha512-s7PoyDv/II1ObgQunCbB9PdLmUcBZcnWOcxDh7O0N/UwDEsHyqkW+Qh28jW+mVuCdx7gLB0BotYI1Y6uI9iyew==", + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.4.1.tgz", + "integrity": "sha512-9fbDAXSBcc6Bs1mZrDYb3XKzDLm4EXXL9sC1LqKP5rZkT6KRr/rf9amVUcODVXgguK/isJz0d0hP72WeaKWsvA==", "dev": true }, "prettier-linter-helpers": { @@ -41524,9 +41542,9 @@ } }, "rollup": { - "version": "2.58.0", - "resolved": "https://registry.npmjs.org/rollup/-/rollup-2.58.0.tgz", - "integrity": "sha512-NOXpusKnaRpbS7ZVSzcEXqxcLDOagN6iFS8p45RkoiMqPHDLwJm758UF05KlMoCRbLBTZsPOIa887gZJ1AiXvw==", + "version": "2.58.3", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-2.58.3.tgz", + "integrity": "sha512-ei27MSw1KhRur4p87Q0/Va2NAYqMXOX++FNEumMBcdreIRLURKy+cE2wcDJKBn0nfmhP2ZGrJkP1XPO+G8FJQw==", "dev": true, "requires": { "fsevents": "~2.3.2" @@ -44096,25 +44114,29 @@ "version": "2.2.0", "resolved": "https://registry.npmjs.org/unexpected-eventemitter/-/unexpected-eventemitter-2.2.0.tgz", "integrity": "sha512-ciEWOd9kJ9sgyzP8Sai9VdMDiGeoKjeaovyzIUgGw82o0OW1/LbLD2Cf8Cs6cBrtLQdzElBFOe8veMt/bSC49g==", - "dev": true + "dev": true, + "requires": {} }, "unexpected-map": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/unexpected-map/-/unexpected-map-2.1.0.tgz", "integrity": "sha512-SNb3RriTl3Z3+ajIbqgmKOBjLu4VpBfZqAhqOgTbs5zj7ZrWp0dCbUv9bjtdhjKvD8OCn0KYCfkbUU9j9CYz/A==", - "dev": true + "dev": true, + "requires": {} }, "unexpected-set": { "version": "3.3.0", "resolved": "https://registry.npmjs.org/unexpected-set/-/unexpected-set-3.3.0.tgz", "integrity": "sha512-TF6GG/ord4jfCyyiGq1BiNgqmRcuoAqqZ7oa2SAU33lpXNV61ZQNuBiI5TglSMasY0lrDi0O6FCE2d8lFuSG4A==", - "dev": true + "dev": true, + "requires": {} }, "unexpected-sinon": { "version": "10.11.2", "resolved": "https://registry.npmjs.org/unexpected-sinon/-/unexpected-sinon-10.11.2.tgz", "integrity": "sha512-N2KIKPweTVs6AK8cDKQTUwu0fGWyGt+cI/UJZ/eltAyOKgsHL9eILttdGfpZjI/iMYcHcbtUwIlXoHfmh6EcBw==", - "dev": true + "dev": true, + "requires": {} }, "unicode-canonical-property-names-ecmascript": { "version": "2.0.0", @@ -44837,9 +44859,9 @@ "dev": true }, "webpack": { - "version": "5.59.1", - "resolved": "https://registry.npmjs.org/webpack/-/webpack-5.59.1.tgz", - "integrity": "sha512-I01IQV9K96FlpXX3V0L4nvd7gb0r7thfuu1IfT2P4uOHOA77nKARAKDYGe/tScSHKnffNIyQhLC8kRXzY4KEHQ==", + "version": "5.60.0", + "resolved": "https://registry.npmjs.org/webpack/-/webpack-5.60.0.tgz", + "integrity": "sha512-OL5GDYi2dKxnwJPSOg2tODgzDxAffN0osgWkZaBo/l3ikCxDFP+tuJT3uF7GyBE3SDBpKML/+a8EobyWAQO3DQ==", "dev": true, "requires": { "@types/eslint-scope": "^3.7.0", @@ -45332,7 +45354,8 @@ "version": "7.5.5", "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.5.tgz", "integrity": "sha512-BAkMFcAzl8as1G/hArkxOxq3G7pjUqQ3gzYbLL0/5zNkph70e+lCoxBGnm6AW1+/aiNeV4fnKqZ8m4GZewmH2w==", - "dev": true + "dev": true, + "requires": {} }, "xdg-basedir": { "version": "4.0.0", diff --git a/package.json b/package.json index f9183e7c70..102e8c9aa6 100644 --- a/package.json +++ b/package.json @@ -130,7 +130,7 @@ "nps": "^5.10.0", "nyc": "^15.1.0", "pidtree": "^0.5.0", - "prettier": "^1.19.1", + "prettier": "^2.4.1", "regenerator-runtime": "0.13.7", "remark": "^14.0.1", "remark-github": "^11.1.1", @@ -187,9 +187,11 @@ "./lib/cli/index.js": false }, "prettier": { - "singleQuote": true, + "arrowParens": "avoid", "bracketSpacing": false, - "endOfLine": "auto" + "endOfLine": "auto", + "singleQuote": true, + "trailingComma": "none" }, "gitter": "https://gitter.im/mochajs/mocha", "husky": { diff --git a/scripts/karma-rollup-plugin.js b/scripts/karma-rollup-plugin.js index cf7b4796b0..ad6f4e4df3 100644 --- a/scripts/karma-rollup-plugin.js +++ b/scripts/karma-rollup-plugin.js @@ -114,7 +114,7 @@ function bundlePreprocessor(config) { const configPromise = loadConfigFile(path.resolve(basePath, configFile)); - return async function(content, file, done) { + return async function (content, file, done) { const {options, warnings} = await configPromise; const config = options[0]; // plugins is always an array diff --git a/scripts/netlify-headers.js b/scripts/netlify-headers.js index b6ee59f2c2..e881423d20 100644 --- a/scripts/netlify-headers.js +++ b/scripts/netlify-headers.js @@ -38,7 +38,7 @@ new AssetGraph({root: dest}) .populate({ followRelations: {type: 'HtmlAnchor', crossorigin: false} }) - .queue(function(assetGraph) { + .queue(function (assetGraph) { const assets = assetGraph.findAssets({ type: 'Html', isInline: false, @@ -47,7 +47,7 @@ new AssetGraph({root: dest}) const headerMap = {}; - assets.forEach(function(asset) { + assets.forEach(function (asset) { const url = '/' + asset.url @@ -58,7 +58,7 @@ new AssetGraph({root: dest}) headerMap[url] = []; } - headers.forEach(function(header) { + headers.forEach(function (header) { const node = asset.parseTree.querySelector( 'meta[http-equiv=' + header + ']' ); @@ -110,12 +110,12 @@ new AssetGraph({root: dest}) console.log('\n## Autogenerated headers:\n'); - Object.keys(headerMap).forEach(function(url) { + Object.keys(headerMap).forEach(function (url) { console.log(url); const httpHeaders = headerMap[url]; - httpHeaders.forEach(function(header) { + httpHeaders.forEach(function (header) { console.log(` ${header}`); }); diff --git a/scripts/update-authors.js b/scripts/update-authors.js index c036c3edff..a21cea8801 100755 --- a/scripts/update-authors.js +++ b/scripts/update-authors.js @@ -38,7 +38,8 @@ const excludeEmails = [ // `Co-authored-by:` in the message body. Both have been used in the past // to indicate multiple authors per commit, with the latter standardized // by GitHub now. -const authorRe = /(^Author:|^Co-authored-by:)\s+(?[^<]+)\s+(?<[^>]+>)/i; +const authorRe = + /(^Author:|^Co-authored-by:)\s+(?[^<]+)\s+(?<[^>]+>)/i; rl.on('line', line => { const match = line.match(authorRe); diff --git a/test/assertions.js b/test/assertions.js index d811f07aab..223e5fba95 100644 --- a/test/assertions.js +++ b/test/assertions.js @@ -308,7 +308,7 @@ module.exports = { ) .addAssertion( ' [not] to have failed with (error|errors) ', - function(expect, result, ...errors) { + function (expect, result, ...errors) { errors.forEach(error => { expect(result, '[not] to have failed').and('[not] to satisfy', { failures: expect.it('to have an item satisfying', { diff --git a/test/browser-specific/esm.spec.mjs b/test/browser-specific/esm.spec.mjs index 477aa505cc..b9b022af74 100644 --- a/test/browser-specific/esm.spec.mjs +++ b/test/browser-specific/esm.spec.mjs @@ -1,9 +1,9 @@ import './fixtures/esm.fixture.mjs'; -it('should register a global if it did not fail', function() { +it('should register a global if it did not fail', function () { expect(window.MOCHA_IS_OK, 'to be ok'); }); -it('should has global Mocha', function() { +it('should has global Mocha', function () { expect(window.Mocha, 'not to be', undefined); }); diff --git a/test/browser-specific/requirejs-setup.js b/test/browser-specific/requirejs-setup.js index 360703778b..8dd5d18979 100644 --- a/test/browser-specific/requirejs-setup.js +++ b/test/browser-specific/requirejs-setup.js @@ -1,5 +1,5 @@ /* eslint-disable strict */ -(function() { +(function () { 'use strict'; var tests = []; diff --git a/test/integration/color.spec.js b/test/integration/color.spec.js index 5e7c306f9d..d21a0073b6 100644 --- a/test/integration/color.spec.js +++ b/test/integration/color.spec.js @@ -3,10 +3,10 @@ var childProcess = require('child_process'); var path = require('path'); -describe('mocha binary', function() { - it('should not output colors to pipe', function(done) { +describe('mocha binary', function () { + it('should not output colors to pipe', function (done) { var command = [path.join('bin', 'mocha'), '--grep', 'missing-test']; - childProcess.execFile(process.execPath, command, function(err, stdout) { + childProcess.execFile(process.execPath, command, function (err, stdout) { if (err) return done(err); expect(stdout, 'not to contain', '[90m'); diff --git a/test/integration/compiler-globbing.spec.js b/test/integration/compiler-globbing.spec.js index 20ea050e4d..b12dcb06a8 100644 --- a/test/integration/compiler-globbing.spec.js +++ b/test/integration/compiler-globbing.spec.js @@ -3,8 +3,8 @@ var exec = require('child_process').exec; var path = require('path'); -describe('globbing like --compilers', function() { - it('should find a file of each type', function(done) { +describe('globbing like --compilers', function () { + it('should find a file of each type', function (done) { exec( '"' + process.execPath + @@ -12,7 +12,7 @@ describe('globbing like --compilers', function() { path.join('bin', 'mocha') + '" -R json --require coffee-script/register --require test/compiler-fixtures/foo.fixture "test/compiler/*.@(coffee|foo)"', {cwd: path.join(__dirname, '..', '..')}, - function(error, stdout) { + function (error, stdout) { if (error && !stdout) { return done(error); } diff --git a/test/integration/config.spec.js b/test/integration/config.spec.js index 4c65f76c24..7009a89044 100644 --- a/test/integration/config.spec.js +++ b/test/integration/config.spec.js @@ -7,8 +7,8 @@ var fs = require('fs'); var path = require('path'); var loadConfig = require('../../lib/cli/config').loadConfig; -describe('config', function() { - it('should return the same values for all supported config types', function() { +describe('config', function () { + it('should return the same values for all supported config types', function () { var configDir = path.join(__dirname, 'fixtures', 'config'); var js = loadConfig(path.join(configDir, 'mocharc.js')); var cjs = loadConfig(path.join(configDir, 'mocharc.cjs')); @@ -19,12 +19,12 @@ describe('config', function() { expect(json, 'to equal', yaml); }); - describe('when configuring Mocha via a ".js" file', function() { + describe('when configuring Mocha via a ".js" file', function () { var projRootDir = path.join(__dirname, '..', '..'); var configDir = path.join(__dirname, 'fixtures', 'config'); var json = loadConfig(path.join(configDir, 'mocharc.json')); - it('should load configuration given absolute path', function() { + it('should load configuration given absolute path', function () { var js; function _loadConfig() { @@ -35,7 +35,7 @@ describe('config', function() { expect(js, 'to equal', json); }); - it('should load configuration given cwd-relative path', function() { + it('should load configuration given cwd-relative path', function () { var relConfigDir = configDir.substring(projRootDir.length + 1); var js; @@ -47,7 +47,7 @@ describe('config', function() { expect(js, 'to equal', json); }); - it('should rethrow error from absolute path configuration', function() { + it('should rethrow error from absolute path configuration', function () { function _loadConfig() { loadConfig(path.join(configDir, 'mocharcWithThrowError.js')); } @@ -57,7 +57,7 @@ describe('config', function() { }); }); - it('should rethrow error from cwd-relative path configuration', function() { + it('should rethrow error from cwd-relative path configuration', function () { var relConfigDir = configDir.substring(projRootDir.length + 1); function _loadConfig() { @@ -70,13 +70,13 @@ describe('config', function() { }); // In other words, path does not begin with '/', './', or '../' - describe('when path is neither absolute or relative', function() { + describe('when path is neither absolute or relative', function () { var nodeModulesDir = path.join(projRootDir, 'node_modules'); var pkgName = 'mocha-config'; var installedLocally = false; var symlinkedPkg = false; - before(function() { + before(function () { try { var srcPath = path.join(configDir, pkgName); var targetPath = path.join(nodeModulesDir, pkgName); @@ -93,7 +93,7 @@ describe('config', function() { } }); - it('should load configuration given module-relative path', function() { + it('should load configuration given module-relative path', function () { var js; if (!installedLocally) { @@ -108,7 +108,7 @@ describe('config', function() { expect(js, 'to equal', json); }); - after(function() { + after(function () { if (symlinkedPkg) { try { fs.unlinkSync(path.join(nodeModulesDir, pkgName)); diff --git a/test/integration/deprecate.spec.js b/test/integration/deprecate.spec.js index aa45eb3655..4d83ebe3b4 100644 --- a/test/integration/deprecate.spec.js +++ b/test/integration/deprecate.spec.js @@ -4,12 +4,12 @@ var assert = require('assert'); var run = require('./helpers').runMocha; var args = []; -describe('utils.deprecate test', function() { - it('should print unique deprecation only once', function(done) { +describe('utils.deprecate test', function () { + it('should print unique deprecation only once', function (done) { run( 'deprecate.fixture.js', args, - function(err, res) { + function (err, res) { if (err) { return done(err); } diff --git a/test/integration/diffs.spec.js b/test/integration/diffs.spec.js index 1606b8579d..2f15fecc0b 100644 --- a/test/integration/diffs.spec.js +++ b/test/integration/diffs.spec.js @@ -16,7 +16,7 @@ function getDiffs(output) { var diffs, i, inDiff, inStackTrace; diffs = []; - output.split('\n').forEach(function(line) { + output.split('\n').forEach(function (line) { if (line.match(/^\s{2}\d+\)/)) { // New spec, e.g. "1) spec title" diffs.push([]); @@ -37,9 +37,9 @@ function getDiffs(output) { } }); - return diffs.map(function(diff) { + return diffs.map(function (diff) { return diff - .filter(function(line) { + .filter(function (line) { return line.trim().length; }) .join('\n'); @@ -60,25 +60,22 @@ function getExpectedOutput() { return output .split(/\s*\/\/ DIFF/) .slice(1) - .map(function(diff) { - return diff - .split('\n') - .filter(Boolean) - .join('\n'); + .map(function (diff) { + return diff.split('\n').filter(Boolean).join('\n'); }); } -describe('diffs', function() { +describe('diffs', function () { var diffs, expected; - before(function(done) { + before(function (done) { // @TODO: It should be removed when Node.js 10 LTS is not supported. const nodeVersion = parseInt(process.version.match(/^v(\d+)\./)[1], 10); if (nodeVersion === 10) { this.skip(); } - run('diffs/diffs.fixture.js', [], function(err, res) { + run('diffs/diffs.fixture.js', [], function (err, res) { if (err) { done(err); return; @@ -101,8 +98,8 @@ describe('diffs', function() { 'should work with objects', 'should show value diffs and not be affected by commas', 'should display diff by data and not like an objects' - ].forEach(function(title, i) { - it(title, function() { + ].forEach(function (title, i) { + it(title, function () { expect(diffs[i], 'to be', expected[i]); }); }); diff --git a/test/integration/duplicate-arguments.spec.js b/test/integration/duplicate-arguments.spec.js index 6dc9d3979e..0e83e043a3 100644 --- a/test/integration/duplicate-arguments.spec.js +++ b/test/integration/duplicate-arguments.spec.js @@ -2,13 +2,13 @@ var runMochaJSON = require('./helpers').runMochaJSON; -describe('when non-array argument is provided multiple times', function() { - describe('when the same argument name is used', function() { - it('should prefer the last value', function(done) { +describe('when non-array argument is provided multiple times', function () { + describe('when the same argument name is used', function () { + it('should prefer the last value', function (done) { runMochaJSON( 'passing-sync', ['--no-async-only', '--async-only', '--no-async-only'], - function(err, result) { + function (err, result) { if (err) { return done(err); } @@ -19,18 +19,19 @@ describe('when non-array argument is provided multiple times', function() { }); }); - describe('when a different argument name is used', function() { - it('should prefer the last value', function(done) { - runMochaJSON('passing-async', ['--timeout', '100', '-t', '10'], function( - err, - result - ) { - if (err) { - return done(err); + describe('when a different argument name is used', function () { + it('should prefer the last value', function (done) { + runMochaJSON( + 'passing-async', + ['--timeout', '100', '-t', '10'], + function (err, result) { + if (err) { + return done(err); + } + expect(result, 'to have failed'); + done(); } - expect(result, 'to have failed'); - done(); - }); + ); }); }); }); diff --git a/test/integration/esm.spec.js b/test/integration/esm.spec.js index 8be983f9c4..8935214aaf 100644 --- a/test/integration/esm.spec.js +++ b/test/integration/esm.spec.js @@ -3,10 +3,10 @@ var path = require('path'); const {runMochaJSON: run, runMochaAsync} = require('./helpers'); var args = []; -describe('esm', function() { - it('should pass a passing esm test that uses esm', function(done) { +describe('esm', function () { + it('should pass a passing esm test that uses esm', function (done) { var fixture = 'esm/esm-success.fixture.mjs'; - run(fixture, args, function(err, result) { + run(fixture, args, function (err, result) { if (err) { done(err); return; @@ -17,9 +17,9 @@ describe('esm', function() { }); }); - it('should fail a failing esm test that uses esm', function(done) { + it('should fail a failing esm test that uses esm', function (done) { var fixture = 'esm/esm-failure.fixture.mjs'; - run(fixture, args, function(err, result) { + run(fixture, args, function (err, result) { if (err) { done(err); return; @@ -33,7 +33,7 @@ describe('esm', function() { }); }); - it('should show file location when there is a syntax error in the test', async function() { + it('should show file location when there is a syntax error in the test', async function () { var fixture = 'esm/syntax-error/esm-syntax-error.fixture.mjs'; const err = await runMochaAsync(fixture, args, {stdio: 'pipe'}).catch( err => err @@ -44,9 +44,9 @@ describe('esm', function() { ); }); - it('should recognize esm files ending with .js due to package.json type flag', function(done) { + it('should recognize esm files ending with .js due to package.json type flag', function (done) { var fixture = 'esm/js-folder/esm-in-js.fixture.js'; - run(fixture, args, function(err, result) { + run(fixture, args, function (err, result) { if (err) { done(err); return; @@ -57,7 +57,7 @@ describe('esm', function() { }); }); - it('should enable requiring/loading a cjs module with "dir" as filename', async function() { + it('should enable requiring/loading a cjs module with "dir" as filename', async function () { var fixture = 'esm/test-that-uses-dir-cjs-require.fixture.js'; const result = await runMochaAsync( fixture, @@ -68,7 +68,7 @@ describe('esm', function() { expect(result, 'to have passed test count', 1); }); - it('should throw an ERR_MODULE_NOT_FOUND and not ERR_REQUIRE_ESM if file imports a non-existing module', async function() { + it('should throw an ERR_MODULE_NOT_FOUND and not ERR_REQUIRE_ESM if file imports a non-existing module', async function () { const fixture = 'esm/type-module/test-that-imports-non-existing-module.fixture.js'; diff --git a/test/integration/events.spec.js b/test/integration/events.spec.js index d66109f878..b1ec4b5b04 100644 --- a/test/integration/events.spec.js +++ b/test/integration/events.spec.js @@ -3,10 +3,10 @@ var helpers = require('./helpers'); var runMochaJSON = helpers.runMochaJSON; -describe('event order', function() { - describe('trivial test case', function() { - it('should assert trivial event order', function(done) { - runMochaJSON('runner/events-basic.fixture.js', [], function(err, res) { +describe('event order', function () { + describe('trivial test case', function () { + it('should assert trivial event order', function (done) { + runMochaJSON('runner/events-basic.fixture.js', [], function (err, res) { if (err) { done(err); return; @@ -20,30 +20,31 @@ describe('event order', function() { }); }); - describe('--bail test case', function() { - it('should assert --bail event order', function(done) { - runMochaJSON('runner/events-bail.fixture.js', ['--bail'], function( - err, - res - ) { - if (err) { - done(err); - return; + describe('--bail test case', function () { + it('should assert --bail event order', function (done) { + runMochaJSON( + 'runner/events-bail.fixture.js', + ['--bail'], + function (err, res) { + if (err) { + done(err); + return; + } + expect(res, 'to have failed with error', 'error test A') + .and('to have failed test count', 1) + .and('to have passed test count', 0); + done(); } - expect(res, 'to have failed with error', 'error test A') - .and('to have failed test count', 1) - .and('to have passed test count', 0); - done(); - }); + ); }); }); - describe('--retries test case', function() { - it('should assert --retries event order', function(done) { + describe('--retries test case', function () { + it('should assert --retries event order', function (done) { runMochaJSON( 'runner/events-retries.fixture.js', ['--retries', '1'], - function(err, res) { + function (err, res) { if (err) { done(err); return; @@ -57,31 +58,32 @@ describe('event order', function() { }); }); - describe('--delay test case', function() { - it('should assert --delay event order', function(done) { - runMochaJSON('runner/events-delay.fixture.js', ['--delay'], function( - err, - res - ) { - if (err) { - done(err); - return; + describe('--delay test case', function () { + it('should assert --delay event order', function (done) { + runMochaJSON( + 'runner/events-delay.fixture.js', + ['--delay'], + function (err, res) { + if (err) { + done(err); + return; + } + expect(res, 'to have passed') + .and('to have passed test count', 2) + .and('to have passed test order', 'test A', 'test B') + .and('to have failed test count', 0); + done(); } - expect(res, 'to have passed') - .and('to have passed test count', 2) - .and('to have passed test order', 'test A', 'test B') - .and('to have failed test count', 0); - done(); - }); + ); }); }); - describe('--retries and --bail test case', function() { - it('should assert --retries event order', function(done) { + describe('--retries and --bail test case', function () { + it('should assert --retries event order', function (done) { runMochaJSON( 'runner/events-bail-retries.fixture.js', ['--retries', '1', '--bail'], - function(err, res) { + function (err, res) { if (err) { done(err); return; diff --git a/test/integration/file-utils.spec.js b/test/integration/file-utils.spec.js index fc09bb1dda..7672e7c420 100644 --- a/test/integration/file-utils.spec.js +++ b/test/integration/file-utils.spec.js @@ -7,12 +7,12 @@ const {touchFile, createTempDir} = require('./helpers'); const SYMLINK_SUPPORT = process.platform !== 'win32'; -describe('file utils', function() { +describe('file utils', function () { let tmpDir; let removeTempDir; let tmpFile; - beforeEach(async function() { + beforeEach(async function () { const result = await createTempDir(); tmpDir = result.dirpath; removeTempDir = result.removeTempDir; @@ -25,12 +25,12 @@ describe('file utils', function() { } }); - afterEach(async function() { + afterEach(async function () { return removeTempDir(); }); - describe('lookupFiles()', function() { - it('should not return broken symlink file path', function() { + describe('lookupFiles()', function () { + it('should not return broken symlink file path', function () { if (!SYMLINK_SUPPORT) { return this.skip(); } @@ -47,12 +47,10 @@ describe('file utils', function() { expect(lookupFiles(tmpDir, ['js'], false), 'to equal', []); }); - it('should accept a glob "path" value', function() { - const res = lookupFiles( - tmpFile('mocha-utils*'), - ['js'], - false - ).map(foundFilepath => path.normalize(foundFilepath)); + it('should accept a glob "path" value', function () { + const res = lookupFiles(tmpFile('mocha-utils*'), ['js'], false).map( + foundFilepath => path.normalize(foundFilepath) + ); let expectedLength = 0; let ex = expect(res, 'to contain', tmpFile('mocha-utils.js')); @@ -66,38 +64,38 @@ describe('file utils', function() { ex.and('to have length', expectedLength); }); - describe('when given `extension` option', function() { - describe('when provided a directory for the filepath', function() { + describe('when given `extension` option', function () { + describe('when provided a directory for the filepath', function () { let filepath; - beforeEach(async function() { + beforeEach(async function () { filepath = tmpFile('mocha-utils-text.txt'); touchFile(filepath); }); - describe('when `extension` option has leading dot', function() { - it('should find the file w/ the extension', function() { + describe('when `extension` option has leading dot', function () { + it('should find the file w/ the extension', function () { expect(lookupFiles(tmpDir, ['.txt']), 'to equal', [filepath]); }); }); - describe('when `extension` option has no leading dot', function() { - it('should find the file w/ the extension', function() { + describe('when `extension` option has no leading dot', function () { + it('should find the file w/ the extension', function () { expect(lookupFiles(tmpDir, ['txt']), 'to equal', [filepath]); }); }); - describe('when directory contains file without multipart extension', function() { + describe('when directory contains file without multipart extension', function () { let filepath; - beforeEach(function() { + beforeEach(function () { filepath = tmpFile('mocha-utils-test.js'); touchFile(filepath); }); - describe('when provided multipart `extension` option', function() { - describe('when `extension` option has no leading dot', function() { - it('should not match the filepath', function() { + describe('when provided multipart `extension` option', function () { + describe('when `extension` option has no leading dot', function () { + it('should not match the filepath', function () { expect( lookupFiles(tmpDir, ['test.js']).map(filepath => path.normalize(filepath) @@ -108,8 +106,8 @@ describe('file utils', function() { }); }); - describe('when `extension` option has a leading dot', function() { - it('should not match the filepath', function() { + describe('when `extension` option has a leading dot', function () { + it('should not match the filepath', function () { expect( lookupFiles(tmpDir, ['.test.js']).map(filepath => path.normalize(filepath) @@ -122,17 +120,17 @@ describe('file utils', function() { }); }); - describe('when directory contains matching file having a multipart extension', function() { + describe('when directory contains matching file having a multipart extension', function () { let filepath; - beforeEach(function() { + beforeEach(function () { filepath = tmpFile('mocha-utils.test.js'); touchFile(filepath); }); - describe('when provided multipart `extension` option', function() { - describe('when `extension` option has no leading dot', function() { - it('should find the matching file', function() { + describe('when provided multipart `extension` option', function () { + describe('when `extension` option has no leading dot', function () { + it('should find the matching file', function () { expect( lookupFiles(tmpDir, ['test.js']).map(filepath => path.normalize(filepath) @@ -143,8 +141,8 @@ describe('file utils', function() { }); }); - describe('when `extension` option has a leading dot', function() { - it('should find the matching file', function() { + describe('when `extension` option has a leading dot', function () { + it('should find the matching file', function () { expect( lookupFiles(tmpDir, ['.test.js']).map(filepath => path.normalize(filepath) @@ -159,17 +157,17 @@ describe('file utils', function() { }); }); - describe('when provided a filepath with no extension', function() { + describe('when provided a filepath with no extension', function () { let filepath; - beforeEach(async function() { + beforeEach(async function () { filepath = tmpFile('mocha-utils.ts'); touchFile(filepath); }); - describe('when `extension` option has a leading dot', function() { - describe('when only provided a single extension', function() { - it('should append provided extensions and find only the matching file', function() { + describe('when `extension` option has a leading dot', function () { + describe('when only provided a single extension', function () { + it('should append provided extensions and find only the matching file', function () { expect( lookupFiles(tmpFile('mocha-utils'), ['.js']).map(foundFilepath => path.normalize(foundFilepath) @@ -180,13 +178,12 @@ describe('file utils', function() { }); }); - describe('when provided multiple extensions', function() { - it('should append provided extensions and find all matching files', function() { + describe('when provided multiple extensions', function () { + it('should append provided extensions and find all matching files', function () { expect( - lookupFiles(tmpFile('mocha-utils'), [ - '.js', - '.ts' - ]).map(foundFilepath => path.normalize(foundFilepath)), + lookupFiles(tmpFile('mocha-utils'), ['.js', '.ts']).map( + foundFilepath => path.normalize(foundFilepath) + ), 'to contain', tmpFile('mocha-utils.js'), filepath @@ -195,9 +192,9 @@ describe('file utils', function() { }); }); - describe('when `extension` option has no leading dot', function() { - describe('when only provided a single extension', function() { - it('should append provided extensions and find only the matching file', function() { + describe('when `extension` option has no leading dot', function () { + describe('when only provided a single extension', function () { + it('should append provided extensions and find only the matching file', function () { expect( lookupFiles(tmpFile('mocha-utils'), ['js']).map(foundFilepath => path.normalize(foundFilepath) @@ -208,13 +205,12 @@ describe('file utils', function() { }); }); - describe('when provided multiple extensions', function() { - it('should append provided extensions and find all matching files', function() { + describe('when provided multiple extensions', function () { + it('should append provided extensions and find all matching files', function () { expect( - lookupFiles(tmpFile('mocha-utils'), [ - 'js', - 'ts' - ]).map(foundFilepath => path.normalize(foundFilepath)), + lookupFiles(tmpFile('mocha-utils'), ['js', 'ts']).map( + foundFilepath => path.normalize(foundFilepath) + ), 'to contain', tmpFile('mocha-utils.js'), filepath @@ -223,32 +219,32 @@ describe('file utils', function() { }); }); - describe('when `extension` option is multipart', function() { + describe('when `extension` option is multipart', function () { let filepath; - beforeEach(function() { + beforeEach(function () { filepath = tmpFile('mocha-utils.test.js'); touchFile(filepath); }); - describe('when `extension` option has no leading dot', function() { - it('should append provided extension and find only the matching file', function() { + describe('when `extension` option has no leading dot', function () { + it('should append provided extension and find only the matching file', function () { expect( - lookupFiles(tmpFile('mocha-utils'), [ - 'test.js' - ]).map(foundFilepath => path.normalize(foundFilepath)), + lookupFiles(tmpFile('mocha-utils'), ['test.js']).map( + foundFilepath => path.normalize(foundFilepath) + ), 'to equal', [filepath] ); }); }); - describe('when `extension` option has leading dot', function() { - it('should append provided extension and find only the matching file', function() { + describe('when `extension` option has leading dot', function () { + it('should append provided extension and find only the matching file', function () { expect( - lookupFiles(tmpFile('mocha-utils'), [ - '.test.js' - ]).map(foundFilepath => path.normalize(foundFilepath)), + lookupFiles(tmpFile('mocha-utils'), ['.test.js']).map( + foundFilepath => path.normalize(foundFilepath) + ), 'to equal', [filepath] ); @@ -257,8 +253,8 @@ describe('file utils', function() { }); }); - describe('when no files match', function() { - it('should throw an exception', function() { + describe('when no files match', function () { + it('should throw an exception', function () { expect(() => lookupFiles(tmpFile('mocha-utils')), 'to throw', { name: 'Error', code: 'ERR_MOCHA_NO_FILES_MATCH_PATTERN' @@ -266,8 +262,8 @@ describe('file utils', function() { }); }); - describe('when looking up a directory and no extensions provided', function() { - it('should throw', function() { + describe('when looking up a directory and no extensions provided', function () { + it('should throw', function () { expect(() => lookupFiles(tmpDir), 'to throw', { name: 'TypeError', code: 'ERR_MOCHA_INVALID_ARG_TYPE', diff --git a/test/integration/glob.spec.js b/test/integration/glob.spec.js index 4284320aa7..c85c072d49 100644 --- a/test/integration/glob.spec.js +++ b/test/integration/glob.spec.js @@ -5,12 +5,12 @@ var path = require('path'); var node = '"' + process.execPath + '"'; -describe('globbing', function() { - describe('by the shell', function() { - it('should find the first level test', function(done) { +describe('globbing', function () { + describe('by the shell', function () { + it('should find the first level test', function (done) { testGlob.shouldSucceed( './*.js', - function(results) { + function (results) { expect( results.stdout, 'to contain', @@ -21,10 +21,10 @@ describe('globbing', function() { ); }); - it('should not find a non-matching pattern', function(done) { + it('should not find a non-matching pattern', function (done) { testGlob.shouldFail( './*-none.js', - function(results) { + function (results) { expect( results.stderr, 'to contain', @@ -35,10 +35,10 @@ describe('globbing', function() { ); }); - it('should handle multiple non-matching patterns', function(done) { + it('should handle multiple non-matching patterns', function (done) { testGlob.shouldFail( './*-none.js ./*-none-twice.js', - function(results) { + function (results) { expect(results.stderr, 'to contain', 'Error: No test files found'); expect(results.stderr, 'not to contain', '*-none'); }, @@ -46,10 +46,10 @@ describe('globbing', function() { ); }); - it('should handle both matching and non-matching patterns in the same command', function(done) { + it('should handle both matching and non-matching patterns in the same command', function (done) { testGlob.shouldSucceed( './*.js ./*-none.js', - function(results) { + function (results) { expect( results.stdout, 'to contain', @@ -66,11 +66,11 @@ describe('globbing', function() { }); }); - describe('by Mocha', function() { - it('should find the first level test', function(done) { + describe('by Mocha', function () { + it('should find the first level test', function (done) { testGlob.shouldSucceed( '"./*.js"', - function(results) { + function (results) { expect( results.stdout, 'to contain', @@ -81,10 +81,10 @@ describe('globbing', function() { ); }); - it('should not find a non-matching pattern', function(done) { + it('should not find a non-matching pattern', function (done) { testGlob.shouldFail( '"./*-none.js"', - function(results) { + function (results) { expect( results.stderr, 'to contain', @@ -95,20 +95,20 @@ describe('globbing', function() { ); }); - it('should handle multiple non-matching patterns', function(done) { + it('should handle multiple non-matching patterns', function (done) { testGlob.shouldFail( '"./*-none.js" "./*-none-twice.js"', - function(results) { + function (results) { expect(results.stderr, 'to contain', 'Error: No test files found'); }, done ); }); - it('should handle both matching and non-matching patterns in the same command', function(done) { + it('should handle both matching and non-matching patterns in the same command', function (done) { testGlob.shouldSucceed( '"./*.js" "./*-none.js"', - function(results) { + function (results) { expect( results.stdout, 'to contain', @@ -124,11 +124,11 @@ describe('globbing', function() { ); }); - describe('double-starred', function() { - it('should find the tests on multiple levels', function(done) { + describe('double-starred', function () { + it('should find the tests on multiple levels', function (done) { testGlob.shouldSucceed( '"./**/*.js"', - function(results) { + function (results) { expect( results.stdout, 'to contain', @@ -139,10 +139,10 @@ describe('globbing', function() { ); }); - it('should not find a non-matching pattern', function(done) { + it('should not find a non-matching pattern', function (done) { testGlob.shouldFail( '"./**/*-none.js"', - function(results) { + function (results) { expect( results.stderr, 'to contain', @@ -153,10 +153,10 @@ describe('globbing', function() { ); }); - it('should handle both matching and non-matching patterns in the same command', function(done) { + it('should handle both matching and non-matching patterns in the same command', function (done) { testGlob.shouldSucceed( '"./**/*.js" "./**/*-none.js"', - function(results) { + function (results) { expect( results.stdout, 'to contain', @@ -187,7 +187,7 @@ var testGlob = { }) }; -var isFlakeyNode = (function() { +var isFlakeyNode = (function () { var version = process.versions.node.split('.'); return ( version[0] === '0' && version[1] === '10' && process.platform === 'win32' @@ -203,7 +203,7 @@ function execMochaWith(validate) { '" -R json-stream --no-config ' + glob, {cwd: path.join(__dirname, 'fixtures', 'glob')}, - function(error, stdout, stderr) { + function (error, stdout, stderr) { try { validate(error, stderr); if (isFlakeyNode && error && stderr === '') { diff --git a/test/integration/hook-err.spec.js b/test/integration/hook-err.spec.js index 8590d2bdf4..373d1b6a61 100644 --- a/test/integration/hook-err.spec.js +++ b/test/integration/hook-err.spec.js @@ -7,19 +7,19 @@ const { } = require('./helpers'); const {bang} = require('../../lib/reporters/base').symbols; -describe('hook error handling', function() { +describe('hook error handling', function () { let lines; - describe('before hook error', function() { + describe('before hook error', function () { before(run('hooks/before-hook-error.fixture.js')); - it('should verify results', function() { + it('should verify results', function () { expect(lines, 'to equal', ['before', bang + 'test 3']); }); }); - describe('before hook error tip', function() { + describe('before hook error tip', function () { before(run('hooks/before-hook-error-tip.fixture.js', onlyErrorTitle())); - it('should verify results', function() { + it('should verify results', function () { expect(lines, 'to equal', [ '1) spec 2', '"before all" hook for "skipped":' @@ -27,8 +27,8 @@ describe('hook error handling', function() { }); }); - describe('before hook root error', function() { - it('should verify results', function(done) { + describe('before hook root error', function () { + it('should verify results', function (done) { runMochaJSON('hooks/before-hook-root-error', [], (err, res) => { if (err) { return done(err); @@ -41,8 +41,8 @@ describe('hook error handling', function() { }); }); - describe('before hook nested error', function() { - it('should verify results', function(done) { + describe('before hook nested error', function () { + it('should verify results', function (done) { runMochaJSON('hooks/before-hook-nested-error', [], (err, res) => { if (err) { return done(err); @@ -59,8 +59,8 @@ describe('hook error handling', function() { }); }); - describe('before hook deepnested error', function() { - it('should verify results', function(done) { + describe('before hook deepnested error', function () { + it('should verify results', function (done) { runMochaJSON('hooks/before-hook-deepnested-error', [], (err, res) => { if (err) { return done(err); @@ -77,22 +77,22 @@ describe('hook error handling', function() { }); }); - describe('before each hook error', function() { + describe('before each hook error', function () { before(run('hooks/before-each-hook-error.fixture.js')); - it('should verify results', function() { + it('should verify results', function () { expect(lines, 'to equal', ['before', bang + 'test 3']); }); }); - describe('after hook error', function() { + describe('after hook error', function () { before(run('hooks/after-hook-error.fixture.js')); - it('should verify results', function() { + it('should verify results', function () { expect(lines, 'to equal', ['test 1', 'test 2', 'after', bang + 'test 3']); }); }); - describe('after hook nested error', function() { - it('should verify results', function(done) { + describe('after hook nested error', function () { + it('should verify results', function (done) { runMochaJSON('hooks/after-hook-nested-error', [], (err, res) => { if (err) { return done(err); @@ -114,8 +114,8 @@ describe('hook error handling', function() { }); }); - describe('after hook deepnested error', function() { - it('should verify results', function(done) { + describe('after hook deepnested error', function () { + it('should verify results', function (done) { runMochaJSON('hooks/after-hook-deepnested-error', [], (err, res) => { if (err) { return done(err); @@ -136,16 +136,16 @@ describe('hook error handling', function() { }); }); - describe('after each hook error', function() { + describe('after each hook error', function () { before(run('hooks/after-each-hook-error.fixture.js')); - it('should verify results', function() { + it('should verify results', function () { expect(lines, 'to equal', ['test 1', 'after', bang + 'test 3']); }); }); - describe('multiple hook errors', function() { + describe('multiple hook errors', function () { before(run('hooks/multiple-hook-error.fixture.js')); - it('should verify results', function() { + it('should verify results', function () { expect(lines, 'to equal', [ 'root before', '1-1 before', @@ -178,18 +178,18 @@ describe('hook error handling', function() { }); }); - describe('async - before hook error', function() { + describe('async - before hook error', function () { before(run('hooks/before-hook-async-error.fixture.js')); - it('should verify results', function() { + it('should verify results', function () { expect(lines, 'to equal', ['before', bang + 'test 3']); }); }); - describe('async - before hook error tip', function() { + describe('async - before hook error tip', function () { before( run('hooks/before-hook-async-error-tip.fixture.js', onlyErrorTitle()) ); - it('should verify results', function() { + it('should verify results', function () { expect(lines, 'to equal', [ '1) spec 2', '"before all" hook for "skipped":' @@ -197,30 +197,30 @@ describe('hook error handling', function() { }); }); - describe('async - before each hook error', function() { + describe('async - before each hook error', function () { before(run('hooks/before-each-hook-async-error.fixture.js')); - it('should verify results', function() { + it('should verify results', function () { expect(lines, 'to equal', ['before', bang + 'test 3']); }); }); - describe('async - after hook error', function() { + describe('async - after hook error', function () { before(run('hooks/after-hook-async-error.fixture.js')); - it('should verify results', function() { + it('should verify results', function () { expect(lines, 'to equal', ['test 1', 'test 2', 'after', bang + 'test 3']); }); }); - describe('async - after each hook error', function() { + describe('async - after each hook error', function () { before(run('hooks/after-each-hook-async-error.fixture.js')); - it('should verify results', function() { + it('should verify results', function () { expect(lines, 'to equal', ['test 1', 'after', bang + 'test 3']); }); }); - describe('async - multiple hook errors', function() { + describe('async - multiple hook errors', function () { before(run('hooks/multiple-hook-async-error.fixture.js')); - it('should verify results', function() { + it('should verify results', function () { expect(lines, 'to equal', [ 'root before', '1-1 before', @@ -253,8 +253,8 @@ describe('hook error handling', function() { }); }); - describe('"this.test.error()-style failure', function() { - it('should fail the associated test', async function() { + describe('"this.test.error()-style failure', function () { + it('should fail the associated test', async function () { return expect( runMochaJSONAsync('hooks/after-each-this-test-error'), 'when fulfilled', diff --git a/test/integration/hooks.spec.js b/test/integration/hooks.spec.js index 727ce1156d..7f345e6274 100644 --- a/test/integration/hooks.spec.js +++ b/test/integration/hooks.spec.js @@ -6,9 +6,9 @@ var runMochaJSON = require('./helpers').runMochaJSON; var SPLIT_DOT_REPORTER_REGEXP = require('./helpers').SPLIT_DOT_REPORTER_REGEXP; var args = ['--reporter', 'dot']; -describe('hooks', function() { - it('are ran in correct order', function(done) { - runMocha('cascade.fixture.js', args, function(err, res) { +describe('hooks', function () { + it('are ran in correct order', function (done) { + runMocha('cascade.fixture.js', args, function (err, res) { var lines, expected; if (err) { @@ -18,10 +18,10 @@ describe('hooks', function() { lines = res.output .split(SPLIT_DOT_REPORTER_REGEXP) - .map(function(line) { + .map(function (line) { return line.trim(); }) - .filter(function(line) { + .filter(function (line) { return line.length; }) .slice(0, -1); @@ -42,7 +42,7 @@ describe('hooks', function() { 'after one' ]; - expected.forEach(function(line, i) { + expected.forEach(function (line, i) { assert.strictEqual(lines[i], line); }); @@ -51,8 +51,8 @@ describe('hooks', function() { }); }); - it('current test title of all hooks', function(done) { - runMochaJSON('current-test-title.fixture.js', [], function(err, res) { + it('current test title of all hooks', function (done) { + runMochaJSON('current-test-title.fixture.js', [], function (err, res) { if (err) { return done(err); } diff --git a/test/integration/init.spec.js b/test/integration/init.spec.js index 3961b27844..d19f42a0b4 100644 --- a/test/integration/init.spec.js +++ b/test/integration/init.spec.js @@ -6,10 +6,10 @@ var invokeMocha = require('./helpers').invokeMocha; var path = require('path'); var os = require('os'); -describe('init command', function() { +describe('init command', function () { var tmpdir; - beforeEach(function() { + beforeEach(function () { tmpdir = path.join(os.tmpdir(), 'mocha-init'); try { fs.mkdirSync(tmpdir); @@ -17,17 +17,17 @@ describe('init command', function() { expect(fs.existsSync(tmpdir), 'to be true'); }); - afterEach(function() { + afterEach(function () { try { rimraf.sync(tmpdir); } catch (ignored) {} }); - describe('when no path is supplied', function() { - it('should fail', function(done) { + describe('when no path is supplied', function () { + it('should fail', function (done) { invokeMocha( ['init'], - function(err, result) { + function (err, result) { if (err) { return done(err); } @@ -41,10 +41,10 @@ describe('init command', function() { {stdio: 'pipe'} ); }); - it('should not throw', function(done) { + it('should not throw', function (done) { invokeMocha( ['init'], - function(err, result) { + function (err, result) { if (err) { return done(err); } @@ -58,10 +58,10 @@ describe('init command', function() { }); }); - it('should create some files in the dest dir', function(done) { + it('should create some files in the dest dir', function (done) { invokeMocha( ['init', tmpdir], - function(err, result) { + function (err, result) { if (err) { return done(err); } diff --git a/test/integration/invalid-arguments.spec.js b/test/integration/invalid-arguments.spec.js index e1eabf20ae..bc39cd2c73 100644 --- a/test/integration/invalid-arguments.spec.js +++ b/test/integration/invalid-arguments.spec.js @@ -2,12 +2,12 @@ var invokeMocha = require('./helpers').invokeMocha; -describe('invalid arguments', function() { - describe('when argument is missing required value', function() { - it('should exit with failure', function(done) { +describe('invalid arguments', function () { + describe('when argument is missing required value', function () { + it('should exit with failure', function (done) { invokeMocha( ['--ui'], - function(err, result) { + function (err, result) { if (err) { return done(err); } diff --git a/test/integration/multiple-done.spec.js b/test/integration/multiple-done.spec.js index b7348ab488..70e142b4eb 100644 --- a/test/integration/multiple-done.spec.js +++ b/test/integration/multiple-done.spec.js @@ -4,125 +4,130 @@ var runMochaJSON = require('./helpers').runMochaJSON; var invokeMocha = require('./helpers').invokeMocha; var MULTIPLE_DONE = require('../../lib/errors').constants.MULTIPLE_DONE; -describe('multiple calls to done()', function() { +describe('multiple calls to done()', function () { var res; - describe('from a spec', function() { - before(function(done) { - runMochaJSON('multiple-done', function(err, result) { + describe('from a spec', function () { + before(function (done) { + runMochaJSON('multiple-done', function (err, result) { res = result; done(err); }); }); - it('results in failure', function() { + it('results in failure', function () { expect(res, 'to have failed test count', 1) .and('to have passed test count', 1) .and('to have pending test count', 0) .and('to have failed'); }); - it('throws a descriptive error', function() { + it('throws a descriptive error', function () { expect(res, 'to have failed with error', { - message: /done\(\) called multiple times in test \(of root suite\) of file.+multiple-done\.fixture\.js/, + message: + /done\(\) called multiple times in test \(of root suite\) of file.+multiple-done\.fixture\.js/, code: MULTIPLE_DONE }); }); }); - describe('with error passed on second call', function() { - before(function(done) { - runMochaJSON('multiple-done-with-error', function(err, result) { + describe('with error passed on second call', function () { + before(function (done) { + runMochaJSON('multiple-done-with-error', function (err, result) { res = result; done(err); }); }); - it('results in failure', function() { + it('results in failure', function () { expect(res, 'to have failed test count', 1) .and('to have passed test count', 1) .and('to have pending test count', 0) .and('to have failed'); }); - it('should throw a descriptive error', function() { + it('should throw a descriptive error', function () { expect(res, 'to have failed with error', { - message: /done\(\) called multiple times in test \(of root suite\) of file.+multiple-done-with-error\.fixture\.js; in addition, done\(\) received error: Error: second error/, + message: + /done\(\) called multiple times in test \(of root suite\) of file.+multiple-done-with-error\.fixture\.js; in addition, done\(\) received error: Error: second error/, code: MULTIPLE_DONE }); }); }); - describe('with multiple specs', function() { - before(function(done) { - runMochaJSON('multiple-done-specs', function(err, result) { + describe('with multiple specs', function () { + before(function (done) { + runMochaJSON('multiple-done-specs', function (err, result) { res = result; done(err); }); }); - it('results in failure', function() { + it('results in failure', function () { expect(res, 'to have failed test count', 1) .and('to have passed test count', 2) .and('to have pending test count', 0) .and('to have failed'); }); - it('correctly attributes the error', function() { + it('correctly attributes the error', function () { expect(res.failures[0], 'to satisfy', { fullTitle: 'suite test1', err: { - message: /done\(\) called multiple times in test of file.+multiple-done-specs\.fixture\.js/, + message: + /done\(\) called multiple times in test of file.+multiple-done-specs\.fixture\.js/, code: MULTIPLE_DONE } }); }); }); - describe('from a before hook', function() { - before(function(done) { - runMochaJSON('multiple-done-before', function(err, result) { + describe('from a before hook', function () { + before(function (done) { + runMochaJSON('multiple-done-before', function (err, result) { res = result; done(err); }); }); - it('results in failure', function() { + it('results in failure', function () { expect(res, 'to have failed test count', 1) .and('to have passed test count', 1) .and('to have pending test count', 0) .and('to have failed'); }); - it('correctly attributes the error', function() { + it('correctly attributes the error', function () { expect(res.failures[0], 'to satisfy', { fullTitle: 'suite1 "before all" hook in "suite1"', err: { - message: /done\(\) called multiple times in hook of file.+multiple-done-before\.fixture\.js/ + message: + /done\(\) called multiple times in hook of file.+multiple-done-before\.fixture\.js/ } }); }); }); - describe('from a "before each" hook', function() { - before(function(done) { - runMochaJSON('multiple-done-before-each', function(err, result) { + describe('from a "before each" hook', function () { + before(function (done) { + runMochaJSON('multiple-done-before-each', function (err, result) { res = result; done(err); }); }); - it('results in a failure', function() { + it('results in a failure', function () { expect(res, 'to have failed test count', 2) .and('to have passed test count', 2) .and('to have pending test count', 0) .and('to have exit code', 2); }); - it('correctly attributes the errors', function() { + it('correctly attributes the errors', function () { expect(res.failures[0], 'to equal', res.failures[1]).and('to satisfy', { fullTitle: 'suite1 "before each" hook in "suite1"', err: { - message: /done\(\) called multiple times in hook of file.+multiple-done-before-each\.fixture\.js/, + message: + /done\(\) called multiple times in hook of file.+multiple-done-before-each\.fixture\.js/, multiple: [ { code: 'ERR_MOCHA_MULTIPLE_DONE' @@ -133,13 +138,13 @@ describe('multiple calls to done()', function() { }); }); - describe('when done() called asynchronously', function() { - before(function(done) { + describe('when done() called asynchronously', function () { + before(function (done) { // we can't be sure that mocha won't fail with an uncaught exception here, which would cause any JSON // output to be befouled; we need to run "raw" and capture STDERR invokeMocha( require.resolve('./fixtures/multiple-done-async.fixture.js'), - function(err, result) { + function (err, result) { res = result; done(err); }, @@ -147,10 +152,11 @@ describe('multiple calls to done()', function() { ); }); - it('results in error', function() { + it('results in error', function () { expect(res, 'to satisfy', { code: expect.it('to be greater than', 0), - output: /done\(\) called multiple times in test \(of root suite\) of file.+multiple-done-async\.fixture\.js/ + output: + /done\(\) called multiple times in test \(of root suite\) of file.+multiple-done-async\.fixture\.js/ }); }); }); diff --git a/test/integration/multiple-runs.spec.js b/test/integration/multiple-runs.spec.js index 255281430e..af65b4e8c3 100644 --- a/test/integration/multiple-runs.spec.js +++ b/test/integration/multiple-runs.spec.js @@ -2,12 +2,12 @@ const {invokeNode} = require('./helpers'); -describe('multiple runs', function() { - it('should be allowed to run multiple times if cleanReferences is turned off', function(done) { +describe('multiple runs', function () { + it('should be allowed to run multiple times if cleanReferences is turned off', function (done) { var path = require.resolve( './fixtures/multiple-runs/run-thrice.fixture.js' ); - invokeNode([path], function(err, res) { + invokeNode([path], function (err, res) { if (err) { done(err); return; @@ -28,13 +28,13 @@ describe('multiple runs', function() { }); }); - it('should not be allowed if cleanReferences is true', function(done) { + it('should not be allowed if cleanReferences is true', function (done) { var path = require.resolve( './fixtures/multiple-runs/clean-references.fixture.js' ); invokeNode( [path], - function(err, res) { + function (err, res) { if (err) { done(err); return; @@ -50,11 +50,11 @@ describe('multiple runs', function() { ); }); - it('should not be allowed if the instance is disposed', function(done) { + it('should not be allowed if the instance is disposed', function (done) { var path = require.resolve('./fixtures/multiple-runs/dispose.fixture.js'); invokeNode( [path, '--directly-dispose'], - function(err, res) { + function (err, res) { if (err) { done(err); return; @@ -67,13 +67,13 @@ describe('multiple runs', function() { ); }); - it('should not be allowed to run while a previous run is in progress', function(done) { + it('should not be allowed to run while a previous run is in progress', function (done) { var path = require.resolve( './fixtures/multiple-runs/start-second-run-if-previous-is-still-running.fixture' ); invokeNode( [path], - function(err, res) { + function (err, res) { if (err) { done(err); return; @@ -85,11 +85,11 @@ describe('multiple runs', function() { ); }); - it('should reset the hooks between runs', function(done) { + it('should reset the hooks between runs', function (done) { var path = require.resolve( './fixtures/multiple-runs/multiple-runs-with-flaky-before-each.fixture' ); - invokeNode([path], function(err, res) { + invokeNode([path], function (err, res) { expect(err, 'to be null'); expect(res.code, 'to be', 0); var results = JSON.parse(res.output); diff --git a/test/integration/no-diff.spec.js b/test/integration/no-diff.spec.js index 1b791c1338..99775abf48 100644 --- a/test/integration/no-diff.spec.js +++ b/test/integration/no-diff.spec.js @@ -3,16 +3,16 @@ var helpers = require('./helpers'); var run = helpers.runMocha; -describe('no-diff', function() { - describe('when enabled', function() { - it('should not display a diff', function(done) { +describe('no-diff', function () { + describe('when enabled', function () { + it('should not display a diff', function (done) { // @TODO: It should be removed when Node.js 10 LTS is not supported. const nodeVersion = parseInt(process.version.match(/^v(\d+)\./)[1], 10); if (nodeVersion === 10) { this.skip(); } - run('no-diff.fixture.js', ['--no-diff'], function(err, res) { + run('no-diff.fixture.js', ['--no-diff'], function (err, res) { if (err) { done(err); return; @@ -24,9 +24,9 @@ describe('no-diff', function() { }); }); - describe('when disabled', function() { - it('should display a diff', function(done) { - run('no-diff.fixture.js', ['--diff'], function(err, res) { + describe('when disabled', function () { + it('should display a diff', function (done) { + run('no-diff.fixture.js', ['--diff'], function (err, res) { if (err) { done(err); return; diff --git a/test/integration/only.spec.js b/test/integration/only.spec.js index 5ea37ae947..fb3aa78f57 100644 --- a/test/integration/only.spec.js +++ b/test/integration/only.spec.js @@ -3,10 +3,10 @@ var run = require('./helpers').runMochaJSON; var assert = require('assert'); -describe('.only()', function() { - describe('bdd', function() { - it('should run only tests that marked as `only`', function(done) { - run('options/only/bdd.fixture.js', ['--ui', 'bdd'], function(err, res) { +describe('.only()', function () { + describe('bdd', function () { + it('should run only tests that marked as `only`', function (done) { + run('options/only/bdd.fixture.js', ['--ui', 'bdd'], function (err, res) { if (err) { done(err); return; @@ -20,9 +20,9 @@ describe('.only()', function() { }); }); - describe('tdd', function() { - it('should run only tests that marked as `only`', function(done) { - run('options/only/tdd.fixture.js', ['--ui', 'tdd'], function(err, res) { + describe('tdd', function () { + it('should run only tests that marked as `only`', function (done) { + run('options/only/tdd.fixture.js', ['--ui', 'tdd'], function (err, res) { if (err) { done(err); return; @@ -36,22 +36,23 @@ describe('.only()', function() { }); }); - describe('qunit', function() { - it('should run only tests that marked as `only`', function(done) { - run('options/only/qunit.fixture.js', ['--ui', 'qunit'], function( - err, - res - ) { - if (err) { - done(err); - return; + describe('qunit', function () { + it('should run only tests that marked as `only`', function (done) { + run( + 'options/only/qunit.fixture.js', + ['--ui', 'qunit'], + function (err, res) { + if (err) { + done(err); + return; + } + assert.strictEqual(res.stats.pending, 0); + assert.strictEqual(res.stats.passes, 5); + assert.strictEqual(res.stats.failures, 0); + assert.strictEqual(res.code, 0); + done(); } - assert.strictEqual(res.stats.pending, 0); - assert.strictEqual(res.stats.passes, 5); - assert.strictEqual(res.stats.failures, 0); - assert.strictEqual(res.code, 0); - done(); - }); + ); }); }); }); diff --git a/test/integration/options/allowUncaught.spec.js b/test/integration/options/allowUncaught.spec.js index 181aba1446..518dd32994 100644 --- a/test/integration/options/allowUncaught.spec.js +++ b/test/integration/options/allowUncaught.spec.js @@ -5,15 +5,15 @@ var helpers = require('../helpers'); var runMocha = helpers.runMocha; var runMochaJSON = helpers.runMochaJSON; -describe('--allow-uncaught', function() { +describe('--allow-uncaught', function () { var args = ['--allow-uncaught']; - it('should throw an uncaught error and exit process', function(done) { + it('should throw an uncaught error and exit process', function (done) { var fixture = path.join('options', 'allow-uncaught', 'propagate'); runMocha( fixture, args, - function(err, res) { + function (err, res) { if (err) { return done(err); } @@ -28,9 +28,9 @@ describe('--allow-uncaught', function() { ); }); - it('should run with conditional `this.skip()`', function(done) { + it('should run with conditional `this.skip()`', function (done) { var fixture = path.join('options', 'allow-uncaught', 'this-skip-it'); - runMochaJSON(fixture, args, function(err, res) { + runMochaJSON(fixture, args, function (err, res) { if (err) { return done(err); } diff --git a/test/integration/options/asyncOnly.spec.js b/test/integration/options/asyncOnly.spec.js index d9e3e8e064..6d23308654 100644 --- a/test/integration/options/asyncOnly.spec.js +++ b/test/integration/options/asyncOnly.spec.js @@ -4,16 +4,16 @@ var path = require('path').posix; var helpers = require('../helpers'); var runMochaJSON = helpers.runMochaJSON; -describe('--async-only', function() { +describe('--async-only', function () { var args = []; - before(function() { + before(function () { args = ['--async-only']; }); - it('should fail synchronous specs', function(done) { + it('should fail synchronous specs', function (done) { var fixture = path.join('options', 'async-only-sync'); - runMochaJSON(fixture, args, function(err, res) { + runMochaJSON(fixture, args, function (err, res) { if (err) { return done(err); } @@ -23,9 +23,9 @@ describe('--async-only', function() { }); }); - it('should allow asynchronous specs', function(done) { + it('should allow asynchronous specs', function (done) { var fixture = path.join('options', 'async-only-async'); - runMochaJSON(fixture, args, function(err, res) { + runMochaJSON(fixture, args, function (err, res) { if (err) { return done(err); } diff --git a/test/integration/options/bail.spec.js b/test/integration/options/bail.spec.js index 95ccba49d4..f55177bed5 100644 --- a/test/integration/options/bail.spec.js +++ b/test/integration/options/bail.spec.js @@ -4,16 +4,16 @@ var path = require('path').posix; var helpers = require('../helpers'); var runMochaJSON = helpers.runMochaJSON; -describe('--bail', function() { +describe('--bail', function () { var args = []; - before(function() { + before(function () { args = ['--bail']; }); - it('should stop after the first error', function(done) { + it('should stop after the first error', function (done) { var fixture = path.join('options', 'bail'); - runMochaJSON(fixture, args, function(err, res) { + runMochaJSON(fixture, args, function (err, res) { if (err) { return done(err); } @@ -27,9 +27,9 @@ describe('--bail', function() { }); }); - it('should stop after the first error - async', function(done) { + it('should stop after the first error - async', function (done) { var fixture = path.join('options', 'bail-async'); - runMochaJSON(fixture, args, function(err, res) { + runMochaJSON(fixture, args, function (err, res) { if (err) { return done(err); } @@ -43,9 +43,9 @@ describe('--bail', function() { }); }); - it('should stop all tests after failing "before" hook', function(done) { + it('should stop all tests after failing "before" hook', function (done) { var fixture = path.join('options', 'bail-with-before'); - runMochaJSON(fixture, args, function(err, res) { + runMochaJSON(fixture, args, function (err, res) { if (err) { return done(err); } @@ -61,9 +61,9 @@ describe('--bail', function() { }); }); - it('should stop all tests after failing "beforeEach" hook', function(done) { + it('should stop all tests after failing "beforeEach" hook', function (done) { var fixture = path.join('options', 'bail-with-beforeEach'); - runMochaJSON(fixture, args, function(err, res) { + runMochaJSON(fixture, args, function (err, res) { if (err) { return done(err); } @@ -79,9 +79,9 @@ describe('--bail', function() { }); }); - it('should stop all tests after failing test', function(done) { + it('should stop all tests after failing test', function (done) { var fixture = path.join('options', 'bail-with-test'); - runMochaJSON(fixture, args, function(err, res) { + runMochaJSON(fixture, args, function (err, res) { if (err) { return done(err); } @@ -94,9 +94,9 @@ describe('--bail', function() { }); }); - it('should stop all tests after failing "after" hook', function(done) { + it('should stop all tests after failing "after" hook', function (done) { var fixture = path.join('options', 'bail-with-after'); - runMochaJSON(fixture, args, function(err, res) { + runMochaJSON(fixture, args, function (err, res) { if (err) { return done(err); } @@ -113,9 +113,9 @@ describe('--bail', function() { }); }); - it('should stop all tests after failing "afterEach" hook', function(done) { + it('should stop all tests after failing "afterEach" hook', function (done) { var fixture = path.join('options', 'bail-with-afterEach'); - runMochaJSON(fixture, args, function(err, res) { + runMochaJSON(fixture, args, function (err, res) { if (err) { return done(err); } diff --git a/test/integration/options/compilers.spec.js b/test/integration/options/compilers.spec.js index 99fa79a7f5..701d21c99e 100644 --- a/test/integration/options/compilers.spec.js +++ b/test/integration/options/compilers.spec.js @@ -3,11 +3,11 @@ var helpers = require('../helpers'); var invokeMocha = helpers.invokeMocha; -describe('--compilers', function() { - it('should report deprecation', function(done) { +describe('--compilers', function () { + it('should report deprecation', function (done) { invokeMocha( ['--compilers', 'coffee:coffee-script/register'], - function(err, res) { + function (err, res) { if (err) { return done(err); } diff --git a/test/integration/options/delay.spec.js b/test/integration/options/delay.spec.js index ae9ff70f29..dc4c284079 100644 --- a/test/integration/options/delay.spec.js +++ b/test/integration/options/delay.spec.js @@ -4,16 +4,16 @@ var path = require('path').posix; var helpers = require('../helpers'); var runMochaJSON = helpers.runMochaJSON; -describe('--delay', function() { +describe('--delay', function () { var args = []; - before(function() { + before(function () { args = ['--delay']; }); - it('should run the generated test suite', function(done) { + it('should run the generated test suite', function (done) { var fixture = path.join('options', 'delay'); - runMochaJSON(fixture, args, function(err, res) { + runMochaJSON(fixture, args, function (err, res) { if (err) { return done(err); } @@ -23,9 +23,9 @@ describe('--delay', function() { }); }); - it('should execute exclusive tests only', function(done) { + it('should execute exclusive tests only', function (done) { var fixture = path.join('options', 'delay-only'); - runMochaJSON(fixture, args, function(err, res) { + runMochaJSON(fixture, args, function (err, res) { if (err) { return done(err); } @@ -41,9 +41,9 @@ describe('--delay', function() { }); }); - it('should throw an error if the test suite failed to run', function(done) { + it('should throw an error if the test suite failed to run', function (done) { var fixture = path.join('options', 'delay-fail'); - runMochaJSON(fixture, args, function(err, res) { + runMochaJSON(fixture, args, function (err, res) { if (err) { return done(err); } diff --git a/test/integration/options/dryRun.spec.js b/test/integration/options/dryRun.spec.js index 81325948ee..ec7b6f9278 100644 --- a/test/integration/options/dryRun.spec.js +++ b/test/integration/options/dryRun.spec.js @@ -4,12 +4,12 @@ var path = require('path').posix; var helpers = require('../helpers'); var runMochaJSON = helpers.runMochaJSON; -describe('--dry-run', function() { +describe('--dry-run', function () { var args = ['--dry-run']; - it('should only report, but not execute any test', function(done) { + it('should only report, but not execute any test', function (done) { var fixture = path.join('options/dry-run', 'dry-run'); - runMochaJSON(fixture, args, function(err, res) { + runMochaJSON(fixture, args, function (err, res) { if (err) { return done(err); } diff --git a/test/integration/options/exit.spec.js b/test/integration/options/exit.spec.js index cde3c35b96..d467249fea 100644 --- a/test/integration/options/exit.spec.js +++ b/test/integration/options/exit.spec.js @@ -2,7 +2,7 @@ var runMocha = require('../helpers').runMocha; -describe('--exit', function() { +describe('--exit', function () { var behaviors = { enabled: '--exit', disabled: '--no-exit' @@ -16,11 +16,11 @@ describe('--exit', function() { } // these two handlers deal with a ctrl-c on command-line - before(function() { + before(function () { process.on('SIGINT', killSubprocess); }); - after(function() { + after(function () { process.removeListener('SIGINT', killSubprocess); }); @@ -33,8 +33,8 @@ describe('--exit', function() { * @param {"enabled"|"disabled"} [behavior] - 'enabled' or 'disabled'; omit for default * @returns {Function} async function implementing the test */ - var runExit = function(shouldExit, behavior) { - return function(done) { + var runExit = function (shouldExit, behavior) { + return function (done) { var timeout = this.timeout(); this.timeout(0); this.slow(Infinity); @@ -53,25 +53,25 @@ describe('--exit', function() { }); // If this callback happens, then Mocha didn't automatically exit. - timeoutObj = setTimeout(function() { + timeoutObj = setTimeout(function () { didExit = false; killSubprocess(); }, timeout - 500); }; }; - describe('default behavior', function() { + describe('default behavior', function () { it('should not force exit after root suite completion', runExit(false)); }); - describe('when enabled', function() { + describe('when enabled', function () { it( 'should force exit after root suite completion', runExit(true, 'enabled') ); }); - describe('when disabled', function() { + describe('when disabled', function () { it( 'should not force exit after root suite completion', runExit(false, 'disabled') diff --git a/test/integration/options/extension.spec.js b/test/integration/options/extension.spec.js index c9f2f4210b..84c0b264dc 100644 --- a/test/integration/options/extension.spec.js +++ b/test/integration/options/extension.spec.js @@ -4,8 +4,8 @@ var helpers = require('../helpers'); var invokeMocha = helpers.invokeMocha; var toJSONResult = helpers.toJSONResult; -describe('--extension', function() { - it('should allow comma-separated variables', function(done) { +describe('--extension', function () { + it('should allow comma-separated variables', function (done) { var args = [ '--require', 'coffee-script/register', @@ -17,7 +17,7 @@ describe('--extension', function() { 'js,coffee', 'test/integration/fixtures/options/extension' ]; - invokeMocha(args, function(err, res) { + invokeMocha(args, function (err, res) { if (err) { return done(err); } @@ -29,7 +29,7 @@ describe('--extension', function() { }); }); - it('should allow extensions beginning with a dot', function(done) { + it('should allow extensions beginning with a dot', function (done) { var args = [ '--require', 'coffee-script/register', @@ -41,7 +41,7 @@ describe('--extension', function() { '.js', 'test/integration/fixtures/options/extension' ]; - invokeMocha(args, function(err, res) { + invokeMocha(args, function (err, res) { if (err) { return done(err); } diff --git a/test/integration/options/failZero.spec.js b/test/integration/options/failZero.spec.js index 02b88c40c2..c0ef4924fe 100644 --- a/test/integration/options/failZero.spec.js +++ b/test/integration/options/failZero.spec.js @@ -3,12 +3,12 @@ var helpers = require('../helpers'); var runMochaJSON = helpers.runMochaJSON; -describe('--fail-zero', function() { +describe('--fail-zero', function () { var args = ['--fail-zero', '--grep', 'yyyyyy']; - it('should fail since no tests are encountered', function(done) { + it('should fail since no tests are encountered', function (done) { var fixture = '__default__.fixture.js'; - runMochaJSON(fixture, args, function(err, res) { + runMochaJSON(fixture, args, function (err, res) { if (err) { return done(err); } diff --git a/test/integration/options/file.spec.js b/test/integration/options/file.spec.js index cbe361d8aa..88815376f0 100644 --- a/test/integration/options/file.spec.js +++ b/test/integration/options/file.spec.js @@ -5,7 +5,7 @@ var helpers = require('../helpers'); var runMochaJSON = helpers.runMochaJSON; var resolvePath = helpers.resolveFixturePath; -describe('--file', function() { +describe('--file', function () { var args = []; var fixtures = { alpha: path.join('options', 'file-alpha'), @@ -13,11 +13,11 @@ describe('--file', function() { theta: path.join('options', 'file-theta') }; - it('should run tests passed via file first', function(done) { + it('should run tests passed via file first', function (done) { args = ['--file', resolvePath(fixtures.alpha)]; var fixture = fixtures.beta; - runMochaJSON(fixture, args, function(err, res) { + runMochaJSON(fixture, args, function (err, res) { if (err) { return done(err); } @@ -28,7 +28,7 @@ describe('--file', function() { }); }); - it('should run multiple tests passed via file first', function(done) { + it('should run multiple tests passed via file first', function (done) { args = [ '--file', resolvePath(fixtures.alpha), @@ -37,7 +37,7 @@ describe('--file', function() { ]; var fixture = fixtures.theta; - runMochaJSON(fixture, args, function(err, res) { + runMochaJSON(fixture, args, function (err, res) { if (err) { return done(err); } @@ -53,10 +53,10 @@ describe('--file', function() { }); }); - it('should support having no other test files', function(done) { + it('should support having no other test files', function (done) { args = ['--file', resolvePath(fixtures.alpha)]; - runMochaJSON('filethatdoesnotexist.js', args, function(err, res) { + runMochaJSON('filethatdoesnotexist.js', args, function (err, res) { if (err) { return done(err); } diff --git a/test/integration/options/forbidOnly.spec.js b/test/integration/options/forbidOnly.spec.js index 252c5b99b9..81dbde2dcd 100644 --- a/test/integration/options/forbidOnly.spec.js +++ b/test/integration/options/forbidOnly.spec.js @@ -5,17 +5,17 @@ var helpers = require('../helpers'); var runMocha = helpers.runMocha; var runMochaJSON = helpers.runMochaJSON; -describe('--forbid-only', function() { +describe('--forbid-only', function () { var args = []; var onlyErrorMessage = '`.only` forbidden'; - beforeEach(function() { + beforeEach(function () { args = ['--forbid-only']; }); - it('should succeed if there are only passed tests', function(done) { + it('should succeed if there are only passed tests', function (done) { var fixture = path.join('options', 'forbid-only', 'passed'); - runMochaJSON(fixture, args, function(err, res) { + runMochaJSON(fixture, args, function (err, res) { if (err) { return done(err); } @@ -24,13 +24,13 @@ describe('--forbid-only', function() { }); }); - it('should fail if there are tests marked only', function(done) { + it('should fail if there are tests marked only', function (done) { var fixture = path.join('options', 'forbid-only', 'only'); var spawnOpts = {stdio: 'pipe'}; runMocha( fixture, args, - function(err, res) { + function (err, res) { if (err) { return done(err); } @@ -41,13 +41,13 @@ describe('--forbid-only', function() { ); }); - it('should fail if there are tests in suites marked only', function(done) { + it('should fail if there are tests in suites marked only', function (done) { var fixture = path.join('options', 'forbid-only', 'only-suite'); var spawnOpts = {stdio: 'pipe'}; runMocha( fixture, args, - function(err, res) { + function (err, res) { if (err) { return done(err); } @@ -58,13 +58,13 @@ describe('--forbid-only', function() { ); }); - it('should fail if there is empty suite marked only', function(done) { + it('should fail if there is empty suite marked only', function (done) { var fixture = path.join('options', 'forbid-only', 'only-empty-suite'); var spawnOpts = {stdio: 'pipe'}; runMocha( fixture, args, - function(err, res) { + function (err, res) { if (err) { return done(err); } @@ -75,13 +75,13 @@ describe('--forbid-only', function() { ); }); - it('should fail if there is suite marked only which matches grep', function(done) { + it('should fail if there is suite marked only which matches grep', function (done) { var fixture = path.join('options', 'forbid-only', 'only-suite'); var spawnOpts = {stdio: 'pipe'}; runMocha( fixture, args.concat('--fgrep', 'suite marked with only'), - function(err, res) { + function (err, res) { if (err) { return done(err); } @@ -92,13 +92,13 @@ describe('--forbid-only', function() { ); }); - it('should fail if suite marked only does not match grep', function(done) { + it('should fail if suite marked only does not match grep', function (done) { var fixture = path.join('options', 'forbid-only', 'only-suite'); var spawnOpts = {stdio: 'pipe'}; runMocha( fixture, args.concat('--fgrep', 'bumble bees'), - function(err, res) { + function (err, res) { if (err) { return done(err); } @@ -109,13 +109,13 @@ describe('--forbid-only', function() { ); }); - it('should fail if suite marked only does not match inverted grep', function(done) { + it('should fail if suite marked only does not match inverted grep', function (done) { var fixture = path.join('options', 'forbid-only', 'only-suite'); var spawnOpts = {stdio: 'pipe'}; runMocha( fixture, args.concat('--fgrep', 'suite marked with only', '--invert'), - function(err, res) { + function (err, res) { if (err) { return done(err); } @@ -126,13 +126,13 @@ describe('--forbid-only', function() { ); }); - it('should fail even if before has "skip"', function(done) { + it('should fail even if before has "skip"', function (done) { var fixture = path.join('options', 'forbid-only', 'only-before'); var spawnOpts = {stdio: 'pipe'}; runMocha( fixture, args, - function(err, res) { + function (err, res) { if (err) { return done(err); } @@ -143,13 +143,13 @@ describe('--forbid-only', function() { ); }); - it('should fail even if beforeEach has "skip"', function(done) { + it('should fail even if beforeEach has "skip"', function (done) { var fixture = path.join('options', 'forbid-only', 'only-before-each'); var spawnOpts = {stdio: 'pipe'}; runMocha( fixture, args, - function(err, res) { + function (err, res) { if (err) { return done(err); } diff --git a/test/integration/options/forbidPending.spec.js b/test/integration/options/forbidPending.spec.js index ab590825a0..d507204401 100644 --- a/test/integration/options/forbidPending.spec.js +++ b/test/integration/options/forbidPending.spec.js @@ -5,17 +5,17 @@ var helpers = require('../helpers'); var runMocha = helpers.runMocha; var runMochaJSON = helpers.runMochaJSON; -describe('--forbid-pending', function() { +describe('--forbid-pending', function () { var args = []; var pendingErrorMessage = 'Pending test forbidden'; - before(function() { + before(function () { args = ['--forbid-pending']; }); - it('should succeed if there are only passed tests', function(done) { + it('should succeed if there are only passed tests', function (done) { var fixture = path.join('options', 'forbid-pending', 'passed'); - runMochaJSON(fixture, args, function(err, res) { + runMochaJSON(fixture, args, function (err, res) { if (err) { return done(err); } @@ -24,13 +24,13 @@ describe('--forbid-pending', function() { }); }); - it('should fail if there are tests in suites marked skip', function(done) { + it('should fail if there are tests in suites marked skip', function (done) { var fixture = path.join('options', 'forbid-pending', 'skip-suite'); var spawnOpts = {stdio: 'pipe'}; runMocha( fixture, args, - function(err, res) { + function (err, res) { if (err) { return done(err); } @@ -44,13 +44,13 @@ describe('--forbid-pending', function() { ); }); - it('should fail if there is empty suite marked pending', function(done) { + it('should fail if there is empty suite marked pending', function (done) { var fixture = path.join('options', 'forbid-pending', 'skip-empty-suite'); var spawnOpts = {stdio: 'pipe'}; runMocha( fixture, args, - function(err, res) { + function (err, res) { if (err) { return done(err); } @@ -72,14 +72,14 @@ describe('--forbid-pending', function() { 'should fail if before calls `skip()`': 'before-this-skip' }; - Object.keys(forbidPendingFailureTests).forEach(function(title) { - it(title, function(done) { + Object.keys(forbidPendingFailureTests).forEach(function (title) { + it(title, function (done) { var fixture = path.join( 'options', 'forbid-pending', forbidPendingFailureTests[title] ); - runMochaJSON(fixture, args, function(err, res) { + runMochaJSON(fixture, args, function (err, res) { if (err) { return done(err); } diff --git a/test/integration/options/grep.spec.js b/test/integration/options/grep.spec.js index 406d763f74..ac573274ab 100644 --- a/test/integration/options/grep.spec.js +++ b/test/integration/options/grep.spec.js @@ -6,9 +6,9 @@ var runMochaJSON = helpers.runMochaJSON; var FIXTURE = 'options/grep'; -describe('--grep', function() { - it('should run specs matching a string', function(done) { - runMochaJSON(FIXTURE, ['--grep', 'match'], function(err, res) { +describe('--grep', function () { + it('should run specs matching a string', function (done) { + runMochaJSON(FIXTURE, ['--grep', 'match'], function (err, res) { if (err) { return done(err); } @@ -19,9 +19,9 @@ describe('--grep', function() { }); }); - describe('should run specs matching a RegExp', function() { - it('with RegExp-like strings (pattern followed by flag)', function(done) { - runMochaJSON(FIXTURE, ['--grep', '/match/i'], function(err, res) { + describe('should run specs matching a RegExp', function () { + it('with RegExp-like strings (pattern followed by flag)', function (done) { + runMochaJSON(FIXTURE, ['--grep', '/match/i'], function (err, res) { if (err) { return done(err); } @@ -32,8 +32,8 @@ describe('--grep', function() { }); }); - it('with string as pattern', function(done) { - runMochaJSON(FIXTURE, ['--grep', '.*'], function(err, res) { + it('with string as pattern', function (done) { + runMochaJSON(FIXTURE, ['--grep', '.*'], function (err, res) { if (err) { return done(err); } @@ -46,26 +46,30 @@ describe('--grep', function() { }); }); - describe('when used with --invert', function() { - it('should run specs that do not match the pattern', function(done) { - runMochaJSON(FIXTURE, ['--grep', 'fail', '--invert'], function(err, res) { - if (err) { - return done(err); + describe('when used with --invert', function () { + it('should run specs that do not match the pattern', function (done) { + runMochaJSON( + FIXTURE, + ['--grep', 'fail', '--invert'], + function (err, res) { + if (err) { + return done(err); + } + expect(res, 'to have passed') + .and('to have passed test count', 4) + .and('not to have pending tests'); + done(); } - expect(res, 'to have passed') - .and('to have passed test count', 4) - .and('not to have pending tests'); - done(); - }); + ); }); }); - describe('when both --fgrep and --grep used together', function() { - it('should report an error', function(done) { + describe('when both --fgrep and --grep used together', function () { + it('should report an error', function (done) { runMocha( FIXTURE, ['--fgrep', 'first', '--grep', 'second'], - function(err, res) { + function (err, res) { if (err) { return done(err); } diff --git a/test/integration/options/ignore.spec.js b/test/integration/options/ignore.spec.js index 85d9de4204..d924a961f0 100644 --- a/test/integration/options/ignore.spec.js +++ b/test/integration/options/ignore.spec.js @@ -5,7 +5,7 @@ var helpers = require('../helpers'); var runMochaJSON = helpers.runMochaJSON; var resolvePath = helpers.resolveFixturePath; -describe('--ignore', function() { +describe('--ignore', function () { /* * Runs mocha in {path} with the given args. * Calls handleResult with the result. @@ -16,7 +16,7 @@ describe('--ignore', function() { * @param {function} done */ function runMochaTest(fixture, args, handleResult, done) { - runMochaJSON(fixture, args, function(err, res) { + runMochaJSON(fixture, args, function (err, res) { if (err) { return done(err); } @@ -26,12 +26,12 @@ describe('--ignore', function() { }); } - it('should ignore specific files', function(done) { + it('should ignore specific files', function (done) { var fixtures = path.join('options', 'ignore', '*'); runMochaTest( fixtures, ['--ignore', resolvePath(path.join('options', 'ignore', 'fail'))], - function(res) { + function (res) { expect(res, 'to have passed') .and('to have run test', 'should find this test') .and('not to have pending tests'); @@ -40,12 +40,12 @@ describe('--ignore', function() { ); }); - it('should ignore globbed files', function(done) { + it('should ignore globbed files', function (done) { var fixtures = path.join('options', 'ignore', '**', '*'); runMochaTest( fixtures, ['--ignore', '**/fail.fixture.js'], - function(res) { + function (res) { expect(res, 'to have passed') .and('not to have pending tests') .and('to have passed test count', 2); @@ -54,7 +54,7 @@ describe('--ignore', function() { ); }); - it('should ignore multiple patterns', function(done) { + it('should ignore multiple patterns', function (done) { var fixtures = path.join('options', 'ignore', '**', '*'); runMochaTest( fixtures, @@ -64,7 +64,7 @@ describe('--ignore', function() { '--ignore', resolvePath(path.join('options', 'ignore', 'nested', 'fail')) ], - function(res) { + function (res) { expect(res, 'to have passed') .and('not to have pending tests') .and('to have passed test count', 2); diff --git a/test/integration/options/invert.spec.js b/test/integration/options/invert.spec.js index a1b5b14ec1..9c8b93f28a 100644 --- a/test/integration/options/invert.spec.js +++ b/test/integration/options/invert.spec.js @@ -2,13 +2,13 @@ var runMocha = require('../helpers').runMocha; -describe('--invert', function() { - describe('when used without --fgrep or --grep', function() { - it('it should report an error', function(done) { +describe('--invert', function () { + describe('when used without --fgrep or --grep', function () { + it('it should report an error', function (done) { runMocha( 'options/grep', ['--invert'], - function(err, res) { + function (err, res) { if (err) { return done(err); } diff --git a/test/integration/options/jobs.spec.js b/test/integration/options/jobs.spec.js index 832d825298..060bef7da9 100644 --- a/test/integration/options/jobs.spec.js +++ b/test/integration/options/jobs.spec.js @@ -3,9 +3,9 @@ var helpers = require('../helpers'); var runMochaAsync = helpers.runMochaAsync; -describe('--jobs', function() { - describe('when set to a number less than 2', function() { - it('should run tests in serial', function() { +describe('--jobs', function () { + describe('when set to a number less than 2', function () { + it('should run tests in serial', function () { return expect( runMochaAsync( 'options/jobs/fail-in-parallel', @@ -18,8 +18,8 @@ describe('--jobs', function() { }); }); - describe('when set to a number greater than 1', function() { - it('should run tests in parallel', function() { + describe('when set to a number greater than 1', function () { + it('should run tests in parallel', function () { return expect( runMochaAsync( 'options/jobs/fail-in-parallel', diff --git a/test/integration/options/listInterfaces.spec.js b/test/integration/options/listInterfaces.spec.js index a9c18a1172..025fc5f846 100644 --- a/test/integration/options/listInterfaces.spec.js +++ b/test/integration/options/listInterfaces.spec.js @@ -5,26 +5,26 @@ var invokeMocha = helpers.invokeMocha; var escapeRegExp = helpers.escapeRegExp; var interfaces = require('../../../lib/mocha').interfaces; -describe('--list-interfaces', function() { - it('should dump a list of all interfaces with descriptions', function(done) { +describe('--list-interfaces', function () { + it('should dump a list of all interfaces with descriptions', function (done) { var expected = Object.keys(interfaces) - .filter(function(name) { + .filter(function (name) { return /^[a-z]/.test(name); }) - .map(function(name) { + .map(function (name) { return { name: escapeRegExp(name), description: escapeRegExp(interfaces[name].description) }; }); - invokeMocha(['--list-interfaces'], function(err, result) { + invokeMocha(['--list-interfaces'], function (err, result) { if (err) { return done(err); } expect(result.code, 'to be', 0); - expected.forEach(function(ui) { + expected.forEach(function (ui) { expect( result.output, 'to match', diff --git a/test/integration/options/listReporters.spec.js b/test/integration/options/listReporters.spec.js index 6cf06e94f2..c7557f521d 100644 --- a/test/integration/options/listReporters.spec.js +++ b/test/integration/options/listReporters.spec.js @@ -5,29 +5,29 @@ var invokeMocha = helpers.invokeMocha; var escapeRegExp = helpers.escapeRegExp; var reporters = require('../../../lib/mocha').reporters; -describe('--list-reporters', function() { - it('should dump a list of all reporters with descriptions', function(done) { +describe('--list-reporters', function () { + it('should dump a list of all reporters with descriptions', function (done) { var expected = Object.keys(reporters) - .filter(function(name) { + .filter(function (name) { return ( /^[a-z]/.test(name) && !(reporters[name].abstract || reporters[name].browserOnly) ); }) - .map(function(name) { + .map(function (name) { return { name: escapeRegExp(name), description: escapeRegExp(reporters[name].description) }; }); - invokeMocha(['--list-reporters'], function(err, result) { + invokeMocha(['--list-reporters'], function (err, result) { if (err) { return done(err); } expect(result.code, 'to be', 0); - expected.forEach(function(reporter) { + expected.forEach(function (reporter) { expect( result.output, 'to match', diff --git a/test/integration/options/node-flags.spec.js b/test/integration/options/node-flags.spec.js index b1a87ac296..53b902f884 100644 --- a/test/integration/options/node-flags.spec.js +++ b/test/integration/options/node-flags.spec.js @@ -2,11 +2,11 @@ var invokeMocha = require('../helpers').invokeMocha; -describe('node flags', function() { - it('should not consider argument values to be node flags', function(done) { +describe('node flags', function () { + it('should not consider argument values to be node flags', function (done) { invokeMocha( ['--require', 'trace-dependency'], - function(err, res) { + function (err, res) { if (err) { return done(err); } @@ -18,11 +18,11 @@ describe('node flags', function() { }); }); -describe('node flags using "--node-option"', function() { - it('should pass fake option to node and fail with node exception', function(done) { +describe('node flags using "--node-option"', function () { + it('should pass fake option to node and fail with node exception', function (done) { invokeMocha( ['--node-option', 'fake-flag'], - function(err, res) { + function (err, res) { if (err) { return done(err); } diff --git a/test/integration/options/opts.spec.js b/test/integration/options/opts.spec.js index 30b129f316..d66db40603 100644 --- a/test/integration/options/opts.spec.js +++ b/test/integration/options/opts.spec.js @@ -2,11 +2,11 @@ var invokeMocha = require('../helpers').invokeMocha; -describe('--opts', function() { - it('should report deprecation', function(done) { +describe('--opts', function () { + it('should report deprecation', function (done) { invokeMocha( ['--opts', './test/mocha.opts'], - function(err, res) { + function (err, res) { if (err) { return done(err); } diff --git a/test/integration/options/parallel.spec.js b/test/integration/options/parallel.spec.js index 7c1a32cc9c..825ef150be 100644 --- a/test/integration/options/parallel.spec.js +++ b/test/integration/options/parallel.spec.js @@ -61,10 +61,10 @@ async function waitForChildPids(pid) { return childPids; } -describe('--parallel', function() { - describe('when a test has a syntax error', function() { - describe('when there is only a single test file', function() { - it('should fail gracefully', async function() { +describe('--parallel', function () { + describe('when a test has a syntax error', function () { + describe('when there is only a single test file', function () { + it('should fail gracefully', async function () { return expect( runMochaAsync('options/parallel/syntax-err', ['--parallel']), 'when fulfilled', @@ -74,8 +74,8 @@ describe('--parallel', function() { }); }); - describe('when there are multiple test files', function() { - it('should fail gracefully', async function() { + describe('when there are multiple test files', function () { + it('should fail gracefully', async function () { return expect( invokeMochaAsync( [resolveFixturePath('options/parallel/syntax-err'), '--parallel'], @@ -88,8 +88,8 @@ describe('--parallel', function() { }); }); - describe('when used with CJS tests', function() { - it('should have the same result as with --no-parallel', async function() { + describe('when used with CJS tests', function () { + it('should have the same result as with --no-parallel', async function () { const expected = await runMochaAsync('options/parallel/test-*', [ '--no-parallel' ]); @@ -106,8 +106,8 @@ describe('--parallel', function() { }); }); - describe('when used with ESM tests', function() { - it('should have the same result as with --no-parallel', async function() { + describe('when used with ESM tests', function () { + it('should have the same result as with --no-parallel', async function () { const expected = getSummary( await invokeMochaAsync([ '--no-parallel', @@ -130,8 +130,8 @@ describe('--parallel', function() { }); }); - describe('when used with --retries', function() { - it('should retry tests appropriately', async function() { + describe('when used with --retries', function () { + it('should retry tests appropriately', async function () { return expect( runMochaAsync('options/parallel/retries-*', ['--parallel']), 'when fulfilled', @@ -146,8 +146,8 @@ describe('--parallel', function() { }); }); - describe('when used with --allow-uncaught', function() { - it('should bubble up an exception', async function() { + describe('when used with --allow-uncaught', function () { + it('should bubble up an exception', async function () { return expect( invokeMochaAsync( [ @@ -166,8 +166,8 @@ describe('--parallel', function() { }); }); - describe('when used with --file', function() { - it('should error out', async function() { + describe('when used with --file', function () { + it('should error out', async function () { return expect( invokeMochaAsync( [ @@ -184,8 +184,8 @@ describe('--parallel', function() { }); }); - describe('when used with --sort', function() { - it('should error out', async function() { + describe('when used with --sort', function () { + it('should error out', async function () { return expect( invokeMochaAsync( [ @@ -202,8 +202,8 @@ describe('--parallel', function() { }); }); - describe('when used with exclusive tests', function() { - it('should error out', async function() { + describe('when used with exclusive tests', function () { + it('should error out', async function () { return expect( invokeMochaAsync( [ @@ -219,8 +219,8 @@ describe('--parallel', function() { }); }); - describe('when used with --bail', function() { - it('should skip some tests', async function() { + describe('when used with --bail', function () { + it('should skip some tests', async function () { const result = await runMochaAsync('options/parallel/test-*', [ '--parallel', '--bail' @@ -235,7 +235,7 @@ describe('--parallel', function() { ); }); - it('should fail', async function() { + it('should fail', async function () { return expect( runMochaAsync('options/parallel/test-*', ['--parallel', '--bail']), 'when fulfilled', @@ -244,8 +244,8 @@ describe('--parallel', function() { }); }); - describe('when encountering a "bail" in context', function() { - it('should skip some tests', async function() { + describe('when encountering a "bail" in context', function () { + it('should skip some tests', async function () { const result = await runMochaAsync('options/parallel/bail', [ '--parallel' ]); @@ -256,7 +256,7 @@ describe('--parallel', function() { ); }); - it('should fail', async function() { + it('should fail', async function () { return expect( runMochaAsync('options/parallel/bail', ['--parallel', '--bail']), 'when fulfilled', @@ -265,8 +265,8 @@ describe('--parallel', function() { }); }); - describe('when used with "grep"', function() { - it('should be equivalent to running in serial', async function() { + describe('when used with "grep"', function () { + it('should be equivalent to running in serial', async function () { const expected = await runMochaAsync('options/parallel/test-*', [ '--no-parallel', '--grep="suite d"' @@ -287,15 +287,15 @@ describe('--parallel', function() { }); }); - describe('reporter equivalence', function() { + describe('reporter equivalence', function () { // each reporter name is duplicated; one is in all lower-case // 'base' is abstract, 'html' is browser-only, others are incompatible const DENY = ['progress', 'base', 'html', 'markdown', 'json-stream']; Object.keys(Mocha.reporters) .filter(name => /^[a-z]/.test(name) && DENY.indexOf(name) === -1) .forEach(reporter => { - describe(`when multiple test files run with --reporter=${reporter}`, function() { - it('should have the same result as when run with --no-parallel', async function() { + describe(`when multiple test files run with --reporter=${reporter}`, function () { + it('should have the same result as when run with --no-parallel', async function () { // note that the output may not be in the same order, as running file // order is non-deterministic in parallel mode const expected = await runMochaAsync('options/parallel/test-*', [ @@ -321,56 +321,56 @@ describe('--parallel', function() { }); }); - describe('when a single test file is run with --reporter=dot', function() { - it('should have the same output as when run with --no-parallel', async function() { + describe('when a single test file is run with --reporter=dot', function () { + it('should have the same output as when run with --no-parallel', async function () { return assertReporterOutputEquality.call(this, 'dot'); }); }); - describe('when a single test file is run with --reporter=doc', function() { - it('should have the same output as when run with --no-parallel', async function() { + describe('when a single test file is run with --reporter=doc', function () { + it('should have the same output as when run with --no-parallel', async function () { return assertReporterOutputEquality.call(this, 'doc'); }); }); - describe('when a single test file is run with --reporter=tap', function() { - it('should have the same output as when run with --no-parallel', async function() { + describe('when a single test file is run with --reporter=tap', function () { + it('should have the same output as when run with --no-parallel', async function () { return assertReporterOutputEquality.call(this, 'tap'); }); }); - describe('when a single test file is run with --reporter=list', function() { - it('should have the same output as when run with --no-parallel', async function() { + describe('when a single test file is run with --reporter=list', function () { + it('should have the same output as when run with --no-parallel', async function () { return assertReporterOutputEquality.call(this, 'list'); }); }); - describe('when a single test file is run with --reporter=min', function() { - it('should have the same output as when run with --no-parallel', async function() { + describe('when a single test file is run with --reporter=min', function () { + it('should have the same output as when run with --no-parallel', async function () { return assertReporterOutputEquality.call(this, 'min'); }); }); - describe('when a single test file is run with --reporter=spec', function() { - it('should have the same output as when run with --no-parallel', async function() { + describe('when a single test file is run with --reporter=spec', function () { + it('should have the same output as when run with --no-parallel', async function () { return assertReporterOutputEquality.call(this, 'spec'); }); }); - describe('when a single test file is run with --reporter=nyan', function() { - it('should have the same output as when run with --no-parallel', async function() { + describe('when a single test file is run with --reporter=nyan', function () { + it('should have the same output as when run with --no-parallel', async function () { return assertReporterOutputEquality.call(this, 'nyan'); }); }); - describe('when a single test file is run with --reporter=landing', function() { - it('should have the same output as when run with --no-parallel', async function() { + describe('when a single test file is run with --reporter=landing', function () { + it('should have the same output as when run with --no-parallel', async function () { return assertReporterOutputEquality.call(this, 'landing'); }); }); - describe('when a single test file is run with --reporter=progress', function() { - it('should fail due to incompatibility', async function() { + describe('when a single test file is run with --reporter=progress', function () { + it('should fail due to incompatibility', async function () { return expect( invokeMochaAsync( [ @@ -389,8 +389,8 @@ describe('--parallel', function() { }); }); - describe('when a single test file is run with --reporter=markdown', function() { - it('should fail due to incompatibility', async function() { + describe('when a single test file is run with --reporter=markdown', function () { + it('should fail due to incompatibility', async function () { return expect( invokeMochaAsync( [ @@ -409,8 +409,8 @@ describe('--parallel', function() { }); }); - describe('when a single test file is run with --reporter=json-stream', function() { - it('should fail due to incompatibility', async function() { + describe('when a single test file is run with --reporter=json-stream', function () { + it('should fail due to incompatibility', async function () { return expect( invokeMochaAsync( [ @@ -429,8 +429,8 @@ describe('--parallel', function() { }); }); - describe('when a single test file is run with --reporter=json', function() { - it('should have the same output as when run with --no-parallel', async function() { + describe('when a single test file is run with --reporter=json', function () { + it('should have the same output as when run with --no-parallel', async function () { // this one has some timings/durations that we can safely ignore const {expected, actual} = await compareReporters('json'); expected.output = JSON.parse(expected.output); @@ -454,8 +454,8 @@ describe('--parallel', function() { }); }); - describe('when a single test file is run with --reporter=xunit', function() { - it('should have the same output as when run with --no-parallel', async function() { + describe('when a single test file is run with --reporter=xunit', function () { + it('should have the same output as when run with --no-parallel', async function () { // durations need replacing const {expected, actual} = await compareReporters('xunit'); expected.output = expected.output @@ -475,7 +475,7 @@ describe('--parallel', function() { }); }); - describe('pool shutdown', function() { + describe('pool shutdown', function () { // these are unusual and deserve some explanation. we start our mocha // subprocess, and in parallel mode, that subprocess spawns more // subprocesses. `invokeMochaAsync` returns a tuple of a `mocha` @@ -496,8 +496,8 @@ describe('--parallel', function() { // still running. this behavior is dependent on `workerpool@6.0.2`, which // added a guarantee that terminating the pool will _wait_ until all child // processes have actually exited. - describe('during normal operation', function() { - it('should not leave orphaned processes around', async function() { + describe('during normal operation', function () { + it('should not leave orphaned processes around', async function () { const [{pid}, promise] = invokeMochaAsync([ resolveFixturePath('options/parallel/test-*'), '--parallel' @@ -521,8 +521,8 @@ describe('--parallel', function() { }); }); - describe('during operation with --bail', function() { - it('should not leave orphaned processes around', async function() { + describe('during operation with --bail', function () { + it('should not leave orphaned processes around', async function () { const [{pid}, promise] = invokeMochaAsync([ resolveFixturePath('options/parallel/test-*'), '--bail', diff --git a/test/integration/options/reporter-option.spec.js b/test/integration/options/reporter-option.spec.js index 976087fb02..5f7b6ba35e 100644 --- a/test/integration/options/reporter-option.spec.js +++ b/test/integration/options/reporter-option.spec.js @@ -3,13 +3,13 @@ var runMocha = require('../helpers').runMocha; var path = require('path'); -describe('--reporter-option', function() { - describe('when given options w/ invalid format', function() { - it('should display an error', function(done) { +describe('--reporter-option', function () { + describe('when given options w/ invalid format', function () { + it('should display an error', function (done) { runMocha( 'passing.fixture.js', ['--reporter-option', 'foo=bar=baz'], - function(err, res) { + function (err, res) { if (err) { return done(err); } @@ -23,7 +23,7 @@ describe('--reporter-option', function() { ); }); - it('should allow comma-separated values', function(done) { + it('should allow comma-separated values', function (done) { runMocha( 'passing.fixture.js', [ @@ -38,7 +38,7 @@ describe('--reporter-option', function() { '--reporter-option', 'foo=bar,baz=quux' ], - function(err, res) { + function (err, res) { if (err) { return done(err); } @@ -52,7 +52,7 @@ describe('--reporter-option', function() { ); }); - it('should allow repeated options', function(done) { + it('should allow repeated options', function (done) { runMocha( 'passing.fixture.js', [ @@ -69,7 +69,7 @@ describe('--reporter-option', function() { '--reporter-option', 'baz=quux' ], - function(err, res) { + function (err, res) { if (err) { return done(err); } diff --git a/test/integration/options/retries.spec.js b/test/integration/options/retries.spec.js index 2f2fdec869..dd22375fba 100644 --- a/test/integration/options/retries.spec.js +++ b/test/integration/options/retries.spec.js @@ -4,13 +4,13 @@ var path = require('path').posix; var helpers = require('../helpers'); var runMochaJSON = helpers.runMochaJSON; -describe('--retries', function() { +describe('--retries', function () { var args = []; - it('should retry test failures after a certain threshold', function(done) { + it('should retry test failures after a certain threshold', function (done) { args = ['--retries', '3']; var fixture = path.join('options', 'retries'); - runMochaJSON(fixture, args, function(err, res) { + runMochaJSON(fixture, args, function (err, res) { if (err) { return done(err); } diff --git a/test/integration/options/sort.spec.js b/test/integration/options/sort.spec.js index df9318762e..4f739488bf 100644 --- a/test/integration/options/sort.spec.js +++ b/test/integration/options/sort.spec.js @@ -4,16 +4,16 @@ var path = require('path').posix; var helpers = require('../helpers'); var runMochaJSON = helpers.runMochaJSON; -describe('--sort', function() { +describe('--sort', function () { var args = []; - before(function() { + before(function () { args = ['--sort']; }); - it('should sort tests in alphabetical order', function(done) { + it('should sort tests in alphabetical order', function (done) { var fixtures = path.join('options', 'sort*'); - runMochaJSON(fixtures, args, function(err, res) { + runMochaJSON(fixtures, args, function (err, res) { if (err) { done(err); return; diff --git a/test/integration/options/timeout.spec.js b/test/integration/options/timeout.spec.js index e2524c12f8..83267bd02f 100644 --- a/test/integration/options/timeout.spec.js +++ b/test/integration/options/timeout.spec.js @@ -3,9 +3,9 @@ var helpers = require('../helpers'); var runMochaJSON = helpers.runMochaJSON; -describe('--timeout', function() { - it('should allow human-readable string value', function(done) { - runMochaJSON('options/slow-test', ['--timeout', '1s'], function(err, res) { +describe('--timeout', function () { + it('should allow human-readable string value', function (done) { + runMochaJSON('options/slow-test', ['--timeout', '1s'], function (err, res) { if (err) { done(err); return; @@ -17,66 +17,70 @@ describe('--timeout', function() { }); }); - it('should allow numeric value', function(done) { - runMochaJSON('options/slow-test', ['--timeout', '1000'], function( - err, - res - ) { - if (err) { - done(err); - return; + it('should allow numeric value', function (done) { + runMochaJSON( + 'options/slow-test', + ['--timeout', '1000'], + function (err, res) { + if (err) { + done(err); + return; + } + expect(res, 'to have failed') + .and('to have passed test count', 1) + .and('to have failed test count', 1); + done(); } - expect(res, 'to have failed') - .and('to have passed test count', 1) - .and('to have failed test count', 1); - done(); - }); + ); }); - it('should allow multiple values', function(done) { + it('should allow multiple values', function (done) { var fixture = 'options/slow-test'; - runMochaJSON(fixture, ['--timeout', '2s', '--timeout', '1000'], function( - err, - res - ) { - if (err) { - done(err); - return; + runMochaJSON( + fixture, + ['--timeout', '2s', '--timeout', '1000'], + function (err, res) { + if (err) { + done(err); + return; + } + expect(res, 'to have failed') + .and('to have passed test count', 1) + .and('to have failed test count', 1); + done(); } - expect(res, 'to have failed') - .and('to have passed test count', 1) - .and('to have failed test count', 1); - done(); - }); + ); }); - it('should disable timeout with "--inspect"', function(done) { + it('should disable timeout with "--inspect"', function (done) { var fixture = 'options/slow-test'; - runMochaJSON(fixture, ['--inspect', '--timeout', '200'], function( - err, - res - ) { - if (err) { - done(err); - return; + runMochaJSON( + fixture, + ['--inspect', '--timeout', '200'], + function (err, res) { + if (err) { + done(err); + return; + } + expect(res, 'to have passed').and('to have passed test count', 2); + done(); } - expect(res, 'to have passed').and('to have passed test count', 2); - done(); - }); + ); }); - it('should disable timeout with "-n inspect"', function(done) { + it('should disable timeout with "-n inspect"', function (done) { var fixture = 'options/slow-test'; - runMochaJSON(fixture, ['-n', 'inspect', '--timeout', '200'], function( - err, - res - ) { - if (err) { - done(err); - return; + runMochaJSON( + fixture, + ['-n', 'inspect', '--timeout', '200'], + function (err, res) { + if (err) { + done(err); + return; + } + expect(res, 'to have passed').and('to have passed test count', 2); + done(); } - expect(res, 'to have passed').and('to have passed test count', 2); - done(); - }); + ); }); }); diff --git a/test/integration/options/ui.spec.js b/test/integration/options/ui.spec.js index 7e3b6363b5..58f745cd58 100644 --- a/test/integration/options/ui.spec.js +++ b/test/integration/options/ui.spec.js @@ -3,28 +3,29 @@ var helpers = require('../helpers'); var runMochaJSON = helpers.runMochaJSON; -describe('--ui', function() { +describe('--ui', function () { var simpleUiPath = require.resolve('../fixtures/simple-ui.fixture'); - it('should load interface and run it', function(done) { - runMochaJSON('test-for-simple-ui', ['--ui', simpleUiPath], function( - err, - res - ) { - if (err) { - done(err); - return; + it('should load interface and run it', function (done) { + runMochaJSON( + 'test-for-simple-ui', + ['--ui', simpleUiPath], + function (err, res) { + if (err) { + done(err); + return; + } + expect(res, 'to have passed'); + done(); } - expect(res, 'to have passed'); - done(); - }); + ); }); - it("should work if required and name added to Mocha's `interfaces` prop", function(done) { + it("should work if required and name added to Mocha's `interfaces` prop", function (done) { runMochaJSON( 'test-for-simple-ui', ['--require', simpleUiPath, '--ui', 'simple-ui'], - function(err, res) { + function (err, res) { if (err) { done(err); return; diff --git a/test/integration/options/watch.spec.js b/test/integration/options/watch.spec.js index 8e76647500..957b4938c3 100644 --- a/test/integration/options/watch.spec.js +++ b/test/integration/options/watch.spec.js @@ -13,8 +13,8 @@ const { DEFAULT_FIXTURE } = require('../helpers'); -describe('--watch', function() { - describe('when enabled', function() { +describe('--watch', function () { + describe('when enabled', function () { /** * @type {string} */ @@ -26,17 +26,17 @@ describe('--watch', function() { this.slow(5000); - beforeEach(async function() { + beforeEach(async function () { const {dirpath, removeTempDir} = await createTempDir(); tempDir = dirpath; cleanup = removeTempDir; }); - afterEach(function() { + afterEach(function () { cleanup(); }); - it('reruns test when watched test file is touched', function() { + it('reruns test when watched test file is touched', function () { const testFile = path.join(tempDir, 'test.js'); copyFixture(DEFAULT_FIXTURE, testFile); @@ -47,7 +47,7 @@ describe('--watch', function() { }); }); - it('reruns test when watched test file crashes', function() { + it('reruns test when watched test file crashes', function () { const testFile = path.join(tempDir, 'test.js'); copyFixture(DEFAULT_FIXTURE, testFile); @@ -60,8 +60,8 @@ describe('--watch', function() { }); }); - describe('when in parallel mode', function() { - it('reruns test when watched test file is touched', function() { + describe('when in parallel mode', function () { + it('reruns test when watched test file is touched', function () { const testFile = path.join(tempDir, 'test.js'); copyFixture(DEFAULT_FIXTURE, testFile); @@ -72,7 +72,7 @@ describe('--watch', function() { }); }); - it('reruns test when watched test file is crashed', function() { + it('reruns test when watched test file is crashed', function () { const testFile = path.join(tempDir, 'test.js'); copyFixture(DEFAULT_FIXTURE, testFile); @@ -86,7 +86,7 @@ describe('--watch', function() { }); }); - it('reruns test when file matching --watch-files changes', function() { + it('reruns test when file matching --watch-files changes', function () { const testFile = path.join(tempDir, 'test.js'); copyFixture(DEFAULT_FIXTURE, testFile); @@ -104,7 +104,7 @@ describe('--watch', function() { }); }); - it('reruns test when file matching --watch-files is added', function() { + it('reruns test when file matching --watch-files is added', function () { const testFile = path.join(tempDir, 'test.js'); copyFixture(DEFAULT_FIXTURE, testFile); @@ -120,7 +120,7 @@ describe('--watch', function() { }); }); - it('reruns test when file matching --watch-files is removed', function() { + it('reruns test when file matching --watch-files is removed', function () { const testFile = path.join(tempDir, 'test.js'); copyFixture(DEFAULT_FIXTURE, testFile); @@ -138,7 +138,7 @@ describe('--watch', function() { }); }); - it('does not rerun test when file not matching --watch-files is changed', function() { + it('does not rerun test when file not matching --watch-files is changed', function () { const testFile = path.join(tempDir, 'test.js'); copyFixture(DEFAULT_FIXTURE, testFile); @@ -156,7 +156,7 @@ describe('--watch', function() { }); }); - it('picks up new test files when they are added', function() { + it('picks up new test files when they are added', function () { const testFile = path.join(tempDir, 'test/a.js'); copyFixture(DEFAULT_FIXTURE, testFile); @@ -174,7 +174,7 @@ describe('--watch', function() { }); }); - it('reruns test when file matching --extension is changed', function() { + it('reruns test when file matching --extension is changed', function () { const testFile = path.join(tempDir, 'test.js'); copyFixture(DEFAULT_FIXTURE, testFile); @@ -192,7 +192,7 @@ describe('--watch', function() { }); }); - it('reruns when "rs\\n" typed', function() { + it('reruns when "rs\\n" typed', function () { const testFile = path.join(tempDir, 'test.js'); copyFixture(DEFAULT_FIXTURE, testFile); @@ -203,7 +203,7 @@ describe('--watch', function() { }); }); - it('reruns test when file starting with . and matching --extension is changed', function() { + it('reruns test when file starting with . and matching --extension is changed', function () { const testFile = path.join(tempDir, 'test.js'); copyFixture(DEFAULT_FIXTURE, testFile); @@ -221,7 +221,7 @@ describe('--watch', function() { }); }); - it('ignores files in "node_modules" and ".git" by default', function() { + it('ignores files in "node_modules" and ".git" by default', function () { const testFile = path.join(tempDir, 'test.js'); copyFixture(DEFAULT_FIXTURE, testFile); @@ -243,7 +243,7 @@ describe('--watch', function() { }); }); - it('ignores files matching --watch-ignore', function() { + it('ignores files matching --watch-ignore', function () { const testFile = path.join(tempDir, 'test.js'); copyFixture(DEFAULT_FIXTURE, testFile); @@ -267,7 +267,7 @@ describe('--watch', function() { }); }); - it('reloads test files when they change', function() { + it('reloads test files when they change', function () { const testFile = path.join(tempDir, 'test.js'); copyFixture('options/watch/test-file-change', testFile); @@ -290,7 +290,7 @@ describe('--watch', function() { }); }); - it('reloads test dependencies when they change', function() { + it('reloads test dependencies when they change', function () { const testFile = path.join(tempDir, 'test.js'); copyFixture('options/watch/test-with-dependency', testFile); @@ -317,7 +317,7 @@ describe('--watch', function() { }); // Regression test for https://github.com/mochajs/mocha/issues/2027 - it('respects --fgrep on re-runs', async function() { + it('respects --fgrep on re-runs', async function () { const testFile = path.join(tempDir, 'test.js'); copyFixture('options/grep', testFile); @@ -335,7 +335,7 @@ describe('--watch', function() { ); }); - describe('with required hooks', function() { + describe('with required hooks', function () { /** * Helper for setting up hook tests * @@ -343,7 +343,7 @@ describe('--watch', function() { * @return {function} */ function setupHookTest(hookName) { - return function() { + return function () { const testFile = path.join(tempDir, 'test.js'); const hookFile = path.join(tempDir, 'hook.js'); @@ -372,7 +372,7 @@ describe('--watch', function() { it('mochaHooks.afterEach runs as expected', setupHookTest('afterEach')); }); - it('should not leak event listeners', function() { + it('should not leak event listeners', function () { this.timeout(20000); const testFile = path.join(tempDir, 'test.js'); copyFixture(DEFAULT_FIXTURE, testFile); diff --git a/test/integration/pending.spec.js b/test/integration/pending.spec.js index 5fe75f7c2d..01b280cdb0 100644 --- a/test/integration/pending.spec.js +++ b/test/integration/pending.spec.js @@ -7,10 +7,10 @@ var invokeNode = helpers.invokeNode; var toJSONResult = helpers.toJSONResult; var args = []; -describe('pending', function() { - describe('pending specs', function() { - it('should be created by omitting a function', function(done) { - run('pending/spec.fixture.js', args, function(err, res) { +describe('pending', function () { + describe('pending specs', function () { + it('should be created by omitting a function', function (done) { + run('pending/spec.fixture.js', args, function (err, res) { if (err) { done(err); return; @@ -22,8 +22,8 @@ describe('pending', function() { done(); }); }); - it('should return the test object when used via shorthand methods', function(done) { - run('pending/skip-shorthand.fixture.js', args, function(err, res) { + it('should return the test object when used via shorthand methods', function (done) { + run('pending/skip-shorthand.fixture.js', args, function (err, res) { if (err) { done(err); return; @@ -35,8 +35,8 @@ describe('pending', function() { done(); }); }); - it('should keep hierarchies of suites', function(done) { - run('pending/skip-hierarchy.fixture.js', args, function(err, res) { + it('should keep hierarchies of suites', function (done) { + run('pending/skip-hierarchy.fixture.js', args, function (err, res) { if (err) { done(err); return; @@ -55,10 +55,10 @@ describe('pending', function() { }); }); - describe('synchronous skip()', function() { - describe('in spec', function() { - it('should immediately skip the spec and run all others', function(done) { - run('pending/skip-sync-spec.fixture.js', args, function(err, res) { + describe('synchronous skip()', function () { + describe('in spec', function () { + it('should immediately skip the spec and run all others', function (done) { + run('pending/skip-sync-spec.fixture.js', args, function (err, res) { if (err) { return done(err); } @@ -73,9 +73,9 @@ describe('pending', function() { }); }); - describe('in after', function() { - it('should throw, but run all tests', function(done) { - run('pending/skip-sync-after.fixture.js', args, function(err, res) { + describe('in after', function () { + it('should throw, but run all tests', function (done) { + run('pending/skip-sync-after.fixture.js', args, function (err, res) { if (err) { return done(err); } @@ -94,9 +94,9 @@ describe('pending', function() { }); }); - describe('in before', function() { - it('should skip all suite specs', function(done) { - run('pending/skip-sync-before.fixture.js', args, function(err, res) { + describe('in before', function () { + it('should skip all suite specs', function (done) { + run('pending/skip-sync-before.fixture.js', args, function (err, res) { if (err) { done(err); return; @@ -108,8 +108,8 @@ describe('pending', function() { done(); }); }); - it('should run before and after hooks', function(done) { - run('pending/skip-sync-before-hooks.fixture.js', function(err, res) { + it('should run before and after hooks', function (done) { + run('pending/skip-sync-before-hooks.fixture.js', function (err, res) { if (err) { return done(err); } @@ -125,8 +125,8 @@ describe('pending', function() { done(); }); }); - it('should skip all sync/async inner before/after hooks', function(done) { - run('pending/skip-sync-before-inner.fixture.js', function(err, res) { + it('should skip all sync/async inner before/after hooks', function (done) { + run('pending/skip-sync-before-inner.fixture.js', function (err, res) { if (err) { return done(err); } @@ -144,29 +144,30 @@ describe('pending', function() { }); }); - describe('in before with nested describe', function() { - it('should skip all suite specs, even if nested', function(done) { - run('pending/skip-sync-before-nested.fixture.js', args, function( - err, - res - ) { - if (err) { - done(err); - return; + describe('in before with nested describe', function () { + it('should skip all suite specs, even if nested', function (done) { + run( + 'pending/skip-sync-before-nested.fixture.js', + args, + function (err, res) { + if (err) { + done(err); + return; + } + assert.strictEqual(res.stats.pending, 3); + assert.strictEqual(res.stats.passes, 0); + assert.strictEqual(res.stats.failures, 0); + assert.strictEqual(res.code, 0); + done(); } - assert.strictEqual(res.stats.pending, 3); - assert.strictEqual(res.stats.passes, 0); - assert.strictEqual(res.stats.failures, 0); - assert.strictEqual(res.code, 0); - done(); - }); + ); }); }); - describe('in beforeEach', function() { - it('should skip all suite specs', function(done) { + describe('in beforeEach', function () { + it('should skip all suite specs', function (done) { var fixture = 'pending/skip-sync-beforeEach.fixture.js'; - run(fixture, args, function(err, res) { + run(fixture, args, function (err, res) { if (err) { return done(err); } @@ -183,9 +184,9 @@ describe('pending', function() { done(); }); }); - it('should skip only two suite specs', function(done) { + it('should skip only two suite specs', function (done) { var fixture = 'pending/skip-sync-beforeEach-cond.fixture.js'; - run(fixture, args, function(err, res) { + run(fixture, args, function (err, res) { if (err) { return done(err); } @@ -205,10 +206,10 @@ describe('pending', function() { }); }); - describe('asynchronous skip()', function() { - describe('in spec', function() { - it('should immediately skip the spec and run all others', function(done) { - run('pending/skip-async-spec.fixture.js', args, function(err, res) { + describe('asynchronous skip()', function () { + describe('in spec', function () { + it('should immediately skip the spec and run all others', function (done) { + run('pending/skip-async-spec.fixture.js', args, function (err, res) { if (err) { return done(err); } @@ -223,9 +224,9 @@ describe('pending', function() { }); }); - describe('in before', function() { - it('should skip all suite specs', function(done) { - run('pending/skip-async-before.fixture.js', args, function(err, res) { + describe('in before', function () { + it('should skip all suite specs', function (done) { + run('pending/skip-async-before.fixture.js', args, function (err, res) { if (err) { done(err); return; @@ -237,8 +238,8 @@ describe('pending', function() { done(); }); }); - it('should run before and after hooks', function(done) { - run('pending/skip-async-before-hooks.fixture.js', function(err, res) { + it('should run before and after hooks', function (done) { + run('pending/skip-async-before-hooks.fixture.js', function (err, res) { if (err) { return done(err); } @@ -256,29 +257,30 @@ describe('pending', function() { }); }); - describe('in before with nested describe', function() { - it('should skip all suite specs, even if nested', function(done) { - run('pending/skip-async-before-nested.fixture.js', args, function( - err, - res - ) { - if (err) { - done(err); - return; + describe('in before with nested describe', function () { + it('should skip all suite specs, even if nested', function (done) { + run( + 'pending/skip-async-before-nested.fixture.js', + args, + function (err, res) { + if (err) { + done(err); + return; + } + assert.strictEqual(res.stats.pending, 3); + assert.strictEqual(res.stats.passes, 0); + assert.strictEqual(res.stats.failures, 0); + assert.strictEqual(res.code, 0); + done(); } - assert.strictEqual(res.stats.pending, 3); - assert.strictEqual(res.stats.passes, 0); - assert.strictEqual(res.stats.failures, 0); - assert.strictEqual(res.code, 0); - done(); - }); + ); }); }); - describe('in beforeEach', function() { - it('should skip all suite specs', function(done) { + describe('in beforeEach', function () { + it('should skip all suite specs', function (done) { var fixture = 'pending/skip-async-beforeEach.fixture.js'; - run(fixture, args, function(err, res) { + run(fixture, args, function (err, res) { if (err) { return done(err); } @@ -298,10 +300,10 @@ describe('pending', function() { }); }); - describe('programmatic usage', function() { - it('should skip the test by listening to test event', function(done) { + describe('programmatic usage', function () { + it('should skip the test by listening to test event', function (done) { var path = require.resolve('./fixtures/pending/programmatic.fixture.js'); - invokeNode([path], function(err, res) { + invokeNode([path], function (err, res) { if (err) { return done(err); } diff --git a/test/integration/plugins/global-fixtures.spec.js b/test/integration/plugins/global-fixtures.spec.js index 5e3acb1a9d..b136dbbd1d 100644 --- a/test/integration/plugins/global-fixtures.spec.js +++ b/test/integration/plugins/global-fixtures.spec.js @@ -11,9 +11,9 @@ const { createTempDir } = require('../helpers'); -describe('global setup/teardown', function() { - describe('when mocha run in serial mode', function() { - it('should execute global setup and teardown', async function() { +describe('global setup/teardown', function () { + describe('when mocha run in serial mode', function () { + it('should execute global setup and teardown', async function () { return expect( runMochaAsync(DEFAULT_FIXTURE, [ '--require', @@ -24,8 +24,8 @@ describe('global setup/teardown', function() { ); }); - describe('when only global teardown is supplied', function() { - it('should run global teardown', async function() { + describe('when only global teardown is supplied', function () { + it('should run global teardown', async function () { return expect( runMochaAsync(DEFAULT_FIXTURE, [ '--require', @@ -38,8 +38,8 @@ describe('global setup/teardown', function() { }); }); - describe('when only global setup is supplied', function() { - it('should run global setup', async function() { + describe('when only global setup is supplied', function () { + it('should run global setup', async function () { return expect( runMochaAsync(DEFAULT_FIXTURE, [ '--require', @@ -52,7 +52,7 @@ describe('global setup/teardown', function() { }); }); - it('should share context', async function() { + it('should share context', async function () { return expect( runMochaAsync(DEFAULT_FIXTURE, [ '--require', @@ -64,8 +64,8 @@ describe('global setup/teardown', function() { ); }); - describe('when supplied multiple functions', function() { - it('should execute them sequentially', async function() { + describe('when supplied multiple functions', function () { + it('should execute them sequentially', async function () { return expect( runMochaAsync(DEFAULT_FIXTURE, [ '--require', @@ -80,12 +80,12 @@ describe('global setup/teardown', function() { }); }); - describe('when run in watch mode', function() { + describe('when run in watch mode', function () { let tempDir; let testFile; let removeTempDir; - beforeEach(async function() { + beforeEach(async function () { const tempInfo = await createTempDir(); tempDir = tempInfo.dirpath; removeTempDir = tempInfo.removeTempDir; @@ -93,13 +93,13 @@ describe('global setup/teardown', function() { copyFixture(DEFAULT_FIXTURE, testFile); }); - afterEach(async function() { + afterEach(async function () { if (removeTempDir) { return removeTempDir(); } }); - it('should execute global setup and teardown', async function() { + it('should execute global setup and teardown', async function () { return expect( runMochaWatchAsync( [ @@ -119,8 +119,8 @@ describe('global setup/teardown', function() { ); }); - describe('when only global teardown is supplied', function() { - it('should run global teardown', async function() { + describe('when only global teardown is supplied', function () { + it('should run global teardown', async function () { return expect( runMochaWatchAsync( [ @@ -140,8 +140,8 @@ describe('global setup/teardown', function() { }); }); - describe('when only global setup is supplied', function() { - it('should run global setup', async function() { + describe('when only global setup is supplied', function () { + it('should run global setup', async function () { return expect( runMochaWatchAsync( [ @@ -161,7 +161,7 @@ describe('global setup/teardown', function() { }); }); - it('should not re-execute the global fixtures', async function() { + it('should not re-execute the global fixtures', async function () { return expect( runMochaWatchAsync( [ @@ -184,8 +184,8 @@ describe('global setup/teardown', function() { }); }); - describe('when mocha run in parallel mode', function() { - it('should execute global setup and teardown', async function() { + describe('when mocha run in parallel mode', function () { + it('should execute global setup and teardown', async function () { return expect( runMochaAsync(DEFAULT_FIXTURE, [ '--parallel', @@ -197,7 +197,7 @@ describe('global setup/teardown', function() { ); }); - it('should share context', async function() { + it('should share context', async function () { return expect( runMochaAsync(DEFAULT_FIXTURE, [ '--parallel', @@ -210,8 +210,8 @@ describe('global setup/teardown', function() { ).and('when fulfilled', 'to contain once', /teardown: this.foo = bar/); }); - describe('when supplied multiple functions', function() { - it('should execute them sequentially', async function() { + describe('when supplied multiple functions', function () { + it('should execute them sequentially', async function () { return expect( runMochaAsync(DEFAULT_FIXTURE, [ '--parallel', @@ -227,12 +227,12 @@ describe('global setup/teardown', function() { }); }); - describe('when run in watch mode', function() { + describe('when run in watch mode', function () { let tempDir; let testFile; let removeTempDir; - beforeEach(async function() { + beforeEach(async function () { const tempInfo = await createTempDir(); tempDir = tempInfo.dirpath; removeTempDir = tempInfo.removeTempDir; @@ -240,13 +240,13 @@ describe('global setup/teardown', function() { copyFixture(DEFAULT_FIXTURE, testFile); }); - afterEach(async function() { + afterEach(async function () { if (removeTempDir) { return removeTempDir(); } }); - it('should execute global setup and teardown', async function() { + it('should execute global setup and teardown', async function () { return expect( runMochaWatchAsync( [ @@ -267,7 +267,7 @@ describe('global setup/teardown', function() { ); }); - it('should not re-execute the global fixtures', async function() { + it('should not re-execute the global fixtures', async function () { return expect( runMochaWatchAsync( [ diff --git a/test/integration/plugins/root-hooks.spec.js b/test/integration/plugins/root-hooks.spec.js index c70e833053..4de08b93cb 100644 --- a/test/integration/plugins/root-hooks.spec.js +++ b/test/integration/plugins/root-hooks.spec.js @@ -12,7 +12,7 @@ function extractHookOutputFromResult(res) { return res.output .trim() .split('\n') - .filter(function(line) { + .filter(function (line) { // every line that begins with whitespace (e.g., the test name) should be ignored; // we just want the console.log messages return /^\S/.test(line); @@ -29,9 +29,9 @@ function runMochaForHookOutput(args, opts) { return invokeMochaAsync(args, opts)[1].then(extractHookOutputFromResult); } -describe('root hooks', function() { - describe('when mocha run in serial mode', function() { - it('should run root hooks when provided via mochaHooks object export', function() { +describe('root hooks', function () { + describe('when mocha run in serial mode', function () { + it('should run root hooks when provided via mochaHooks object export', function () { return expect( runMochaForHookOutput([ '--require=' + @@ -64,7 +64,7 @@ describe('root hooks', function() { ); }); - it('should run root hooks when provided via mochaHooks function export', function() { + it('should run root hooks when provided via mochaHooks function export', function () { return expect( runMochaForHookOutput([ '--require=' + @@ -97,8 +97,8 @@ describe('root hooks', function() { ); }); - describe('support ESM when type=module or .mjs extension', function() { - it('should run root hooks when provided via mochaHooks', function() { + describe('support ESM when type=module or .mjs extension', function () { + it('should run root hooks when provided via mochaHooks', function () { return expect( runMochaForHookOutput([ '--require=' + @@ -135,8 +135,8 @@ describe('root hooks', function() { }); }); - describe('support ESM via .js extension w/o type=module', function() { - it('should fail due to ambiguous file type', function() { + describe('support ESM via .js extension w/o type=module', function () { + it('should fail due to ambiguous file type', function () { return expect( invokeMochaAsync( [ @@ -156,8 +156,8 @@ describe('root hooks', function() { }); }); - describe('when mocha in parallel mode', function() { - it('should run root hooks when provided via mochaHooks object exports', function() { + describe('when mocha in parallel mode', function () { + it('should run root hooks when provided via mochaHooks object exports', function () { return expect( runMochaForHookOutput([ '--require=' + @@ -191,7 +191,7 @@ describe('root hooks', function() { ); }); - it('should run root hooks when provided via mochaHooks function export', function() { + it('should run root hooks when provided via mochaHooks function export', function () { return expect( runMochaForHookOutput([ '--require=' + @@ -225,8 +225,8 @@ describe('root hooks', function() { ); }); - describe('when running multiple jobs', function() { - it('should run root hooks when provided via mochaHooks object exports for each job', function() { + describe('when running multiple jobs', function () { + it('should run root hooks when provided via mochaHooks object exports for each job', function () { return expect( runMochaForHookOutput([ '--require=' + diff --git a/test/integration/regression.spec.js b/test/integration/regression.spec.js index 0cf644e6b3..f6ae4c1c33 100644 --- a/test/integration/regression.spec.js +++ b/test/integration/regression.spec.js @@ -3,13 +3,13 @@ var run = require('./helpers').runMocha; var runJSON = require('./helpers').runMochaJSON; -describe('regressions', function() { - it('issue-1991: Declarations do not get cleaned up unless you set them to `null` - Memory Leak', function(done) { +describe('regressions', function () { + it('issue-1991: Declarations do not get cleaned up unless you set them to `null` - Memory Leak', function (done) { // on a modern MBP takes ±5 seconds on node 4.0, but on older laptops with node 0.12 ±40 seconds. // Could easily take longer on even weaker machines (Travis-CI containers for example). this.timeout(120000); this.slow(12000); - run('regression/issue-1991.fixture.js', [], function(err, res) { + run('regression/issue-1991.fixture.js', [], function (err, res) { if (err) { done(err); return; @@ -21,24 +21,24 @@ describe('regressions', function() { }); }); - describe("issue-2286: after doesn't execute if test was skipped in beforeEach", function() { + describe("issue-2286: after doesn't execute if test was skipped in beforeEach", function () { var afterWasRun = false; - describe('suite with skipped test for meta test', function() { - beforeEach(function() { + describe('suite with skipped test for meta test', function () { + beforeEach(function () { this.skip(); }); - after(function() { + after(function () { afterWasRun = true; }); - it('should be pending', function() {}); + it('should be pending', function () {}); }); - after('meta test', function() { + after('meta test', function () { expect(afterWasRun, 'to be', true); }); }); - it('issue-2315: cannot read property currentRetry of undefined', function(done) { - runJSON('regression/issue-2315.fixture.js', [], function(err, res) { + it('issue-2315: cannot read property currentRetry of undefined', function (done) { + runJSON('regression/issue-2315.fixture.js', [], function (err, res) { if (err) { done(err); return; @@ -50,8 +50,8 @@ describe('regressions', function() { }); }); - it('issue-2406: should run nested describe.only suites', function(done) { - runJSON('regression/issue-2406.fixture.js', [], function(err, res) { + it('issue-2406: should run nested describe.only suites', function (done) { + runJSON('regression/issue-2406.fixture.js', [], function (err, res) { if (err) { done(err); return; @@ -63,8 +63,8 @@ describe('regressions', function() { }); }); - it('issue-2417: should not recurse infinitely with .only suites nested within each other', function(done) { - runJSON('regression/issue-2417.fixture.js', [], function(err, res) { + it('issue-2417: should not recurse infinitely with .only suites nested within each other', function (done) { + runJSON('regression/issue-2417.fixture.js', [], function (err, res) { if (err) { done(err); return; diff --git a/test/integration/reporters.spec.js b/test/integration/reporters.spec.js index 17bbcd2f41..cdc15b8233 100644 --- a/test/integration/reporters.spec.js +++ b/test/integration/reporters.spec.js @@ -6,33 +6,34 @@ var crypto = require('crypto'); var path = require('path'); var run = require('./helpers').runMocha; -describe('reporters', function() { - describe('markdown', function() { +describe('reporters', function () { + describe('markdown', function () { var res; - before(function(done) { - run('passing.fixture.js', ['--reporter', 'markdown'], function( - err, - result - ) { - res = result; - done(err); - }); + before(function (done) { + run( + 'passing.fixture.js', + ['--reporter', 'markdown'], + function (err, result) { + res = result; + done(err); + } + ); }); - it('does not exceed maximum callstack (issue: 1875)', function() { + it('does not exceed maximum callstack (issue: 1875)', function () { expect(res.output, 'not to contain', 'RangeError'); }); - it('contains spec src', function() { + it('contains spec src', function () { var src = ['```js', 'assert(true);', '```'].join('\n'); expect(res.output, 'to contain', src); }); }); - describe('xunit', function() { - it('prints test cases with --reporter-options output (issue: 1864)', function(done) { + describe('xunit', function () { + it('prints test cases with --reporter-options output (issue: 1864)', function (done) { var randomStr = crypto.randomBytes(8).toString('hex'); var tmpDir = os.tmpdir().replace(new RegExp(path.sep + '$'), ''); var tmpFile = tmpDir + path.sep + 'test-issue-1864-' + randomStr + '.xml'; @@ -48,13 +49,13 @@ describe('reporters', function() { '' ]; - run('passing.fixture.js', args, function(err, result) { + run('passing.fixture.js', args, function (err, result) { if (err) return done(err); var xml = fs.readFileSync(tmpFile, 'utf8'); fs.unlinkSync(tmpFile); - expectedOutput.forEach(function(line) { + expectedOutput.forEach(function (line) { expect(xml, 'to contain', line); }); @@ -63,14 +64,14 @@ describe('reporters', function() { }); }); - describe('loader', function() { - it('loads a reporter from a path relative to the current working directory', function(done) { + describe('loader', function () { + it('loads a reporter from a path relative to the current working directory', function (done) { var reporterAtARelativePath = 'test/integration/fixtures/simple-reporter.js'; var args = ['--reporter=' + reporterAtARelativePath]; - run('passing.fixture.js', args, function(err, result) { + run('passing.fixture.js', args, function (err, result) { if (err) { done(err); return; @@ -80,7 +81,7 @@ describe('reporters', function() { }); }); - it('loads a reporter from an absolute path', function(done) { + it('loads a reporter from an absolute path', function (done) { // Generates an absolute path string var reporterAtAnAbsolutePath = path.join( process.cwd(), @@ -89,7 +90,7 @@ describe('reporters', function() { var args = ['--reporter=' + reporterAtAnAbsolutePath]; - run('passing.fixture.js', args, function(err, result) { + run('passing.fixture.js', args, function (err, result) { if (err) { done(err); return; @@ -100,28 +101,28 @@ describe('reporters', function() { }); }); - describe('tap', function() { - var not = function(predicate) { - return function() { + describe('tap', function () { + var not = function (predicate) { + return function () { return !predicate.apply(this, arguments); }; }; - var versionPredicate = function(line) { + var versionPredicate = function (line) { return line.match(/^TAP version \d+$/) != null; }; - var planPredicate = function(line) { + var planPredicate = function (line) { return line.match(/^1\.\.\d+$/) != null; }; - var testLinePredicate = function(line) { + var testLinePredicate = function (line) { return line.match(/^not ok/) != null || line.match(/^ok/) != null; }; - var diagnosticPredicate = function(line) { + var diagnosticPredicate = function (line) { return line.match(/^#/) != null; }; - var bailOutPredicate = function(line) { + var bailOutPredicate = function (line) { return line.match(/^Bail out!/) != null; }; - var anythingElsePredicate = function(line) { + var anythingElsePredicate = function (line) { return ( versionPredicate(line) === false && planPredicate(line) === false && @@ -131,12 +132,12 @@ describe('reporters', function() { ); }; - describe('produces valid TAP v13 output', function() { - var runFixtureAndValidateOutput = function(fixture, expected) { - it('for ' + fixture, function(done) { + describe('produces valid TAP v13 output', function () { + var runFixtureAndValidateOutput = function (fixture, expected) { + it('for ' + fixture, function (done) { var args = ['--reporter=tap', '--reporter-option', 'tapVersion=13']; - run(fixture, args, function(err, res) { + run(fixture, args, function (err, res) { if (err) { done(err); return; @@ -157,7 +158,7 @@ describe('reporters', function() { // plan must appear once expect(outputLines, 'to contain', expectedPlan); expect( - outputLines.filter(function(l) { + outputLines.filter(function (l) { return l === expectedPlan; }), 'to have length', @@ -170,11 +171,8 @@ describe('reporters', function() { var lastTestLine = outputLines.length - 1 - - outputLines - .slice() - .reverse() - .findIndex(testLinePredicate); - var planLine = outputLines.findIndex(function(line) { + outputLines.slice().reverse().findIndex(testLinePredicate); + var planLine = outputLines.findIndex(function (line) { return line === expectedPlan; }); expect( @@ -196,7 +194,7 @@ describe('reporters', function() { }); }); - it('should fail if given invalid `tapVersion`', function(done) { + it('should fail if given invalid `tapVersion`', function (done) { var invalidTapVersion = 'nosuch'; var args = [ '--reporter=tap', @@ -207,7 +205,7 @@ describe('reporters', function() { run( 'reporters.fixture.js', args, - function(err, res) { + function (err, res) { if (err) { done(err); return; @@ -224,10 +222,10 @@ describe('reporters', function() { ); }); - it('places exceptions correctly in YAML blocks', function(done) { + it('places exceptions correctly in YAML blocks', function (done) { var args = ['--reporter=tap', '--reporter-option', 'tapVersion=13']; - run('reporters.fixture.js', args, function(err, res) { + run('reporters.fixture.js', args, function (err, res) { if (err) { done(err); return; diff --git a/test/integration/retries.spec.js b/test/integration/retries.spec.js index bb5ae51898..a9cb46a42c 100644 --- a/test/integration/retries.spec.js +++ b/test/integration/retries.spec.js @@ -6,12 +6,12 @@ var runJSON = helpers.runMochaJSON; var args = []; var bang = require('../../lib/reporters/base').symbols.bang; -describe('retries', function() { - it('are ran in correct order', function(done) { +describe('retries', function () { + it('are ran in correct order', function (done) { helpers.runMocha( 'retries/hooks.fixture.js', ['--reporter', 'dot'], - function(err, res) { + function (err, res) { var lines, expected; if (err) { @@ -21,10 +21,10 @@ describe('retries', function() { lines = res.output .split(helpers.SPLIT_DOT_REPORTER_REGEXP) - .map(function(line) { + .map(function (line) { return line.trim(); }) - .filter(function(line) { + .filter(function (line) { return line.length; }) .slice(0, -1); @@ -49,7 +49,7 @@ describe('retries', function() { 'after' ]; - expected.forEach(function(line, i) { + expected.forEach(function (line, i) { assert.strictEqual(lines[i], line); }); @@ -59,8 +59,8 @@ describe('retries', function() { ); }); - it('should exit early if test passes', function(done) { - runJSON('retries/early-pass.fixture.js', args, function(err, res) { + it('should exit early if test passes', function (done) { + runJSON('retries/early-pass.fixture.js', args, function (err, res) { if (err) { return done(err); } @@ -74,8 +74,8 @@ describe('retries', function() { }); }); - it('should let test override', function(done) { - runJSON('retries/nested.fixture.js', args, function(err, res) { + it('should let test override', function (done) { + runJSON('retries/nested.fixture.js', args, function (err, res) { if (err) { done(err); return; @@ -89,11 +89,11 @@ describe('retries', function() { }); }); - it('should not hang w/ async test', function(done) { + it('should not hang w/ async test', function (done) { helpers.runMocha( 'retries/async.fixture.js', ['--reporter', 'dot'], - function(err, res) { + function (err, res) { var lines, expected; if (err) { @@ -103,10 +103,10 @@ describe('retries', function() { lines = res.output .split(helpers.SPLIT_DOT_REPORTER_REGEXP) - .map(function(line) { + .map(function (line) { return line.trim(); }) - .filter(function(line) { + .filter(function (line) { return line.length; }) .slice(0, -1); @@ -125,7 +125,7 @@ describe('retries', function() { 'after' ]; - expected.forEach(function(line, i) { + expected.forEach(function (line, i) { assert.strictEqual(lines[i], line); }); diff --git a/test/integration/suite.spec.js b/test/integration/suite.spec.js index db743597b8..1b4c147261 100644 --- a/test/integration/suite.spec.js +++ b/test/integration/suite.spec.js @@ -3,12 +3,12 @@ var run = require('./helpers').runMocha; var args = []; -describe('suite w/no callback', function() { - it('should throw a helpful error message when a callback for suite is not supplied', function(done) { +describe('suite w/no callback', function () { + it('should throw a helpful error message when a callback for suite is not supplied', function (done) { run( 'suite/suite-no-callback.fixture.js', args, - function(err, res) { + function (err, res) { if (err) { return done(err); } @@ -24,23 +24,27 @@ describe('suite w/no callback', function() { }); }); -describe('skipped suite w/no callback', function() { - it('should not throw an error when a callback for skipped suite is not supplied', function(done) { - run('suite/suite-skipped-no-callback.fixture.js', args, function(err, res) { - if (err) { - return done(err); +describe('skipped suite w/no callback', function () { + it('should not throw an error when a callback for skipped suite is not supplied', function (done) { + run( + 'suite/suite-skipped-no-callback.fixture.js', + args, + function (err, res) { + if (err) { + return done(err); + } + var pattern = /TypeError/g; + var result = res.output.match(pattern) || []; + expect(result, 'to have length', 0); + done(); } - var pattern = /TypeError/g; - var result = res.output.match(pattern) || []; - expect(result, 'to have length', 0); - done(); - }); + ); }); }); -describe('skipped suite w/ callback', function() { - it('should not throw an error when a callback for skipped suite is supplied', function(done) { - run('suite/suite-skipped-callback.fixture.js', args, function(err, res) { +describe('skipped suite w/ callback', function () { + it('should not throw an error when a callback for skipped suite is supplied', function (done) { + run('suite/suite-skipped-callback.fixture.js', args, function (err, res) { if (err) { return done(err); } @@ -52,12 +56,12 @@ describe('skipped suite w/ callback', function() { }); }); -describe('suite returning a value', function() { - it('should not give a deprecation warning for suite callback returning a value', function(done) { +describe('suite returning a value', function () { + it('should not give a deprecation warning for suite callback returning a value', function (done) { run( 'suite/suite-returning-value.fixture.js', args, - function(err, res) { + function (err, res) { if (err) { return done(err); } diff --git a/test/integration/timeout.spec.js b/test/integration/timeout.spec.js index 0f98467acc..066c1bcdba 100644 --- a/test/integration/timeout.spec.js +++ b/test/integration/timeout.spec.js @@ -4,9 +4,9 @@ var assert = require('assert'); var run = require('./helpers').runMochaJSON; var args = []; -describe('this.timeout()', function() { - it('is respected by sync and async suites', function(done) { - run('timeout.fixture.js', args, function(err, res) { +describe('this.timeout()', function () { + it('is respected by sync and async suites', function (done) { + run('timeout.fixture.js', args, function (err, res) { if (err) { done(err); return; @@ -19,8 +19,8 @@ describe('this.timeout()', function() { }); }); - it('should allow overriding if disabled per-test', function(done) { - run('timeout-override.fixture.js', args, function(err, res) { + it('should allow overriding if disabled per-test', function (done) { + run('timeout-override.fixture.js', args, function (err, res) { if (err) { done(err); return; diff --git a/test/integration/uncaught.spec.js b/test/integration/uncaught.spec.js index 0e538d4687..96b90c2ff7 100644 --- a/test/integration/uncaught.spec.js +++ b/test/integration/uncaught.spec.js @@ -9,9 +9,9 @@ const { } = require('./helpers'); var args = []; -describe('uncaught exceptions', function() { - it('handles uncaught exceptions from hooks', function(done) { - run('uncaught/hook', args, function(err, res) { +describe('uncaught exceptions', function () { + it('handles uncaught exceptions from hooks', function (done) { + run('uncaught/hook', args, function (err, res) { if (err) { return done(err); } @@ -26,8 +26,8 @@ describe('uncaught exceptions', function() { }); }); - it('handles uncaught exceptions from async specs', function(done) { - run('uncaught/double', args, function(err, res) { + it('handles uncaught exceptions from async specs', function (done) { + run('uncaught/double', args, function (err, res) { if (err) { return done(err); } @@ -46,8 +46,8 @@ describe('uncaught exceptions', function() { }); }); - it('handles uncaught exceptions from which Mocha cannot recover', function(done) { - run('uncaught/fatal', args, function(err, res) { + it('handles uncaught exceptions from which Mocha cannot recover', function (done) { + run('uncaught/fatal', args, function (err, res) { if (err) { return done(err); } @@ -63,8 +63,8 @@ describe('uncaught exceptions', function() { }); }); - it('handles uncaught exceptions within pending tests', function(done) { - run('uncaught/pending', args, function(err, res) { + it('handles uncaught exceptions within pending tests', function (done) { + run('uncaught/pending', args, function (err, res) { if (err) { return done(err); } @@ -86,8 +86,8 @@ describe('uncaught exceptions', function() { }); }); - it('handles uncaught exceptions within open tests', function(done) { - run('uncaught/recover', args, function(err, res) { + it('handles uncaught exceptions within open tests', function (done) { + run('uncaught/recover', args, function (err, res) { if (err) { return done(err); } @@ -113,8 +113,8 @@ describe('uncaught exceptions', function() { }); }); - it('removes uncaught exceptions handlers correctly', function(done) { - invokeNode([resolveFixturePath('uncaught/listeners')], function(err, res) { + it('removes uncaught exceptions handlers correctly', function (done) { + invokeNode([resolveFixturePath('uncaught/listeners')], function (err, res) { if (err) { return done(err); } @@ -124,11 +124,11 @@ describe('uncaught exceptions', function() { }); }); - it("handles uncaught exceptions after runner's end", function(done) { + it("handles uncaught exceptions after runner's end", function (done) { runMocha( 'uncaught/after-runner', args, - function(err, res) { + function (err, res) { if (err) { return done(err); } @@ -146,8 +146,8 @@ describe('uncaught exceptions', function() { ); }); - it('issue-1327: should run the first test and then bail', function(done) { - run('uncaught/issue-1327', args, function(err, res) { + it('issue-1327: should run the first test and then bail', function (done) { + run('uncaught/issue-1327', args, function (err, res) { if (err) { return done(err); } @@ -160,8 +160,8 @@ describe('uncaught exceptions', function() { }); }); - it('issue-1417: uncaught exceptions from async specs', function(done) { - run('uncaught/issue-1417', args, function(err, res) { + it('issue-1417: uncaught exceptions from async specs', function (done) { + run('uncaught/issue-1417', args, function (err, res) { if (err) { return done(err); } @@ -177,9 +177,9 @@ describe('uncaught exceptions', function() { }); }); - describe('issue-4481: behavior of non-Mocha-originating unhandled rejections', function() { - describe('when Node is in "warn" mode', function() { - it('should warn', async function() { + describe('issue-4481: behavior of non-Mocha-originating unhandled rejections', function () { + describe('when Node is in "warn" mode', function () { + it('should warn', async function () { const [, promise] = invokeMochaAsync( [ resolveFixturePath('uncaught/unhandled'), @@ -197,8 +197,8 @@ describe('uncaught exceptions', function() { }); }); - describe('when Node is in "strict" mode', function() { - it('should fail with an uncaught exception', async function() { + describe('when Node is in "strict" mode', function () { + it('should fail with an uncaught exception', async function () { const [, promise] = invokeMochaAsync( [ resolveFixturePath('uncaught/unhandled'), diff --git a/test/interfaces/bdd.spec.js b/test/interfaces/bdd.spec.js index a8f3141b39..b96b386db5 100644 --- a/test/interfaces/bdd.spec.js +++ b/test/interfaces/bdd.spec.js @@ -1,66 +1,68 @@ 'use strict'; -describe('integer primitives', function() { - describe('arithmetic', function() { - it('should add', function() { +describe('integer primitives', function () { + describe('arithmetic', function () { + it('should add', function () { expect(1 + 1, 'to be', 2); expect(2 + 2, 'to be', 4); }); - it('should subtract', function() { + it('should subtract', function () { expect(1 - 1, 'to be', 0); expect(2 - 1, 'to be', 1); }); }); }); -describe('integer primitives', function() { - describe('arithmetic is not', function() { - it('should add', function() { +describe('integer primitives', function () { + describe('arithmetic is not', function () { + it('should add', function () { expect(1 + 1, 'not to equal', 3); expect(2 + 2, 'not to equal', 5); }); }); }); -context('test suite', function() { - beforeEach(function() { +context('test suite', function () { + beforeEach(function () { this.number = 5; }); - specify('share a property', function() { + specify('share a property', function () { expect(this.number, 'to be', 5); }); }); -describe('pending suite', function() { - describe.skip('this is pending suite', function() { - it('should not run', function() { +describe('pending suite', function () { + describe.skip('this is pending suite', function () { + it('should not run', function () { expect(1 + 1, 'to be', 3); }); }); }); -describe('pending tests', function() { - it.skip('should not run', function() { +describe('pending tests', function () { + it.skip('should not run', function () { expect(1 + 1, 'to be', 3); }); }); -describe('setting timeout by appending it to test', function() { - var runningTest = it('enables users to call timeout on active tests', function() { - expect(1 + 1, 'to be', 2); - }).timeout(1003); +describe('setting timeout by appending it to test', function () { + var runningTest = + it('enables users to call timeout on active tests', function () { + expect(1 + 1, 'to be', 2); + }).timeout(1003); - var skippedTest = xit('enables users to call timeout on pending tests', function() { - expect(1 + 1, 'to be', 3); - }).timeout(1002); + var skippedTest = + xit('enables users to call timeout on pending tests', function () { + expect(1 + 1, 'to be', 3); + }).timeout(1002); - it('sets timeout on pending tests', function() { + it('sets timeout on pending tests', function () { expect(skippedTest._timeout, 'to be', 1002); }); - it('sets timeout on running tests', function() { + it('sets timeout on running tests', function () { expect(runningTest._timeout, 'to be', 1003); }); }); diff --git a/test/interfaces/exports.spec.js b/test/interfaces/exports.spec.js index 4b84bda35f..ab2742a9c1 100644 --- a/test/interfaces/exports.spec.js +++ b/test/interfaces/exports.spec.js @@ -3,11 +3,11 @@ var calls = []; exports.Array = { - before: function() { + before: function () { calls.push('before'); }, - after: function() { + after: function () { calls.push('after'); expect(calls, 'to equal', [ 'before', @@ -22,21 +22,21 @@ exports.Array = { }, '#indexOf()': { - beforeEach: function() { + beforeEach: function () { calls.push('before each'); }, - afterEach: function() { + afterEach: function () { calls.push('after each'); }, - 'should return -1 when the value is not present': function() { + 'should return -1 when the value is not present': function () { calls.push('one'); expect([1, 2, 3].indexOf(5), 'to be', -1); expect([1, 2, 3].indexOf(0), 'to be', -1); }, - 'should return the correct index when the value is present': function() { + 'should return the correct index when the value is present': function () { calls.push('two'); expect([1, 2, 3].indexOf(1), 'to be', 0); expect([1, 2, 3].indexOf(2), 'to be', 1); diff --git a/test/interfaces/qunit.spec.js b/test/interfaces/qunit.spec.js index ad5bd9f371..8a555cbb09 100644 --- a/test/interfaces/qunit.spec.js +++ b/test/interfaces/qunit.spec.js @@ -2,11 +2,11 @@ suite('integer primitives'); -test('should add', function() { +test('should add', function () { expect(2 + 2, 'to be', 4); }); -test('should decrement', function() { +test('should decrement', function () { var number = 3; expect(--number, 'to be', 2); expect(--number, 'to be', 1); @@ -15,6 +15,6 @@ test('should decrement', function() { suite('String'); -test('#length', function() { +test('#length', function () { expect('foo', 'to have length', 3); }); diff --git a/test/interfaces/tdd.spec.js b/test/interfaces/tdd.spec.js index 89de8157cd..357ef5a643 100644 --- a/test/interfaces/tdd.spec.js +++ b/test/interfaces/tdd.spec.js @@ -1,40 +1,40 @@ 'use strict'; -suite('integer primitives', function() { - suite('arithmetic', function() { +suite('integer primitives', function () { + suite('arithmetic', function () { var initialValue = 41; - suiteSetup(function(done) { + suiteSetup(function (done) { expect(initialValue, 'to be', 41); initialValue += 1; done(); }); - test('should add', function() { + test('should add', function () { expect(initialValue, 'to be', 42); expect(1 + 1, 'to be', 2); expect(2 + 2, 'to be', 4); }); - test('should subtract', function() { + test('should subtract', function () { expect(initialValue, 'to be', 42); expect(1 - 1, 'to be', 0); expect(2 - 1, 'to be', 1); }); - test.skip('should skip this test', function() { + test.skip('should skip this test', function () { var zero = 0; expect(zero, 'to be', 1); }); - suite.skip('should skip this suite', function() { - test('should skip this test', function() { + suite.skip('should skip this suite', function () { + test('should skip this test', function () { var zero = 0; expect(zero, 'to be', 1); }); }); - suiteTeardown(function(done) { + suiteTeardown(function (done) { expect(initialValue, 'to be', 42); done(); }); diff --git a/test/jsapi/index.js b/test/jsapi/index.js index 1aa842eb08..f3c334349e 100644 --- a/test/jsapi/index.js +++ b/test/jsapi/index.js @@ -20,6 +20,6 @@ mocha.addFile('test/unit/duration.spec.js'); mocha.addFile('test/unit/globals.spec.js'); mocha.addFile('test/unit/timeout.spec.js'); -mocha.run(function() { +mocha.run(function () { console.log('done'); }); diff --git a/test/node-unit/buffered-worker-pool.spec.js b/test/node-unit/buffered-worker-pool.spec.js index b6f1dae039..097640757b 100644 --- a/test/node-unit/buffered-worker-pool.spec.js +++ b/test/node-unit/buffered-worker-pool.spec.js @@ -3,7 +3,7 @@ const rewiremock = require('rewiremock/node'); const sinon = require('sinon'); -describe('class BufferedWorkerPool', function() { +describe('class BufferedWorkerPool', function () { let BufferedWorkerPool; let pool; let stats; @@ -11,7 +11,7 @@ describe('class BufferedWorkerPool', function() { let serializer; let result; - beforeEach(function() { + beforeEach(function () { stats = {totalWorkers: 10, busyWorkers: 8, idleWorkers: 2, pendingTasks: 3}; result = {failures: 0, events: []}; pool = { @@ -40,13 +40,13 @@ describe('class BufferedWorkerPool', function() { BufferedWorkerPool.resetOptionsCache(); }); - afterEach(function() { + afterEach(function () { sinon.restore(); }); - describe('static method', function() { - describe('create()', function() { - it('should return a BufferedWorkerPool instance', function() { + describe('static method', function () { + describe('create()', function () { + it('should return a BufferedWorkerPool instance', function () { expect( BufferedWorkerPool.create({foo: 'bar'}), 'to be a', @@ -54,21 +54,21 @@ describe('class BufferedWorkerPool', function() { ); }); - describe('when passed no arguments', function() { - it('should not throw', function() { + describe('when passed no arguments', function () { + it('should not throw', function () { expect(BufferedWorkerPool.create, 'not to throw'); }); }); }); - describe('serializeOptions()', function() { - describe('when passed no arguments', function() { - it('should not throw', function() { + describe('serializeOptions()', function () { + describe('when passed no arguments', function () { + it('should not throw', function () { expect(BufferedWorkerPool.serializeOptions, 'not to throw'); }); }); - it('should return a serialized string', function() { + it('should return a serialized string', function () { expect( BufferedWorkerPool.serializeOptions({foo: 'bar'}), 'to be a', @@ -76,15 +76,15 @@ describe('class BufferedWorkerPool', function() { ); }); - describe('when called multiple times with the same object', function() { - it('should not perform serialization twice', function() { + describe('when called multiple times with the same object', function () { + it('should not perform serialization twice', function () { const obj = {foo: 'bar'}; BufferedWorkerPool.serializeOptions(obj); BufferedWorkerPool.serializeOptions(obj); expect(serializeJavascript, 'was called once'); }); - it('should return the same value', function() { + it('should return the same value', function () { const obj = {foo: 'bar'}; expect( BufferedWorkerPool.serializeOptions(obj), @@ -96,8 +96,8 @@ describe('class BufferedWorkerPool', function() { }); }); - describe('constructor', function() { - it('should apply defaults', function() { + describe('constructor', function () { + it('should apply defaults', function () { expect(new BufferedWorkerPool(), 'to satisfy', { options: { workerType: 'process', @@ -108,37 +108,37 @@ describe('class BufferedWorkerPool', function() { }); }); - describe('instance method', function() { + describe('instance method', function () { let workerPool; - beforeEach(function() { + beforeEach(function () { workerPool = BufferedWorkerPool.create(); }); - describe('stats()', function() { - it('should return the object returned by `workerpool.Pool#stats`', function() { + describe('stats()', function () { + it('should return the object returned by `workerpool.Pool#stats`', function () { expect(workerPool.stats(), 'to be', stats); }); }); - describe('run()', function() { - describe('when passed no arguments', function() { - it('should reject', async function() { + describe('run()', function () { + describe('when passed no arguments', function () { + it('should reject', async function () { return expect(workerPool.run(), 'to be rejected with', { code: 'ERR_MOCHA_INVALID_ARG_TYPE' }); }); }); - describe('when passed a non-string filepath', function() { - it('should reject', async function() { + describe('when passed a non-string filepath', function () { + it('should reject', async function () { return expect(workerPool.run(123), 'to be rejected with', { code: 'ERR_MOCHA_INVALID_ARG_TYPE' }); }); }); - it('should serialize the options object', async function() { + it('should serialize the options object', async function () { await workerPool.run('file.js', {foo: 'bar'}); expect(pool.exec, 'to have a call satisfying', [ @@ -147,7 +147,7 @@ describe('class BufferedWorkerPool', function() { ]).and('was called once'); }); - it('should deserialize the result', async function() { + it('should deserialize the result', async function () { await workerPool.run('file.js', {foo: 'bar'}); expect(serializer.deserialize, 'to have a call satisfying', [ result @@ -155,25 +155,25 @@ describe('class BufferedWorkerPool', function() { }); }); - describe('terminate()', function() { - describe('when called with `force`', function() { - beforeEach(async function() { + describe('terminate()', function () { + describe('when called with `force`', function () { + beforeEach(async function () { await workerPool.terminate(true); }); - it('should delegate to the underlying pool w/ "force" behavior', async function() { + it('should delegate to the underlying pool w/ "force" behavior', async function () { expect(pool.terminate, 'to have a call satisfying', [true]).and( 'was called once' ); }); }); - describe('when called without `force`', function() { - beforeEach(async function() { + describe('when called without `force`', function () { + beforeEach(async function () { await workerPool.terminate(); }); - it('should delegate to the underlying pool w/o "force" behavior', async function() { + it('should delegate to the underlying pool w/o "force" behavior', async function () { expect(pool.terminate, 'to have a call satisfying', [false]).and( 'was called once' ); diff --git a/test/node-unit/cli/config.spec.js b/test/node-unit/cli/config.spec.js index 270e3ec95a..edd182c373 100644 --- a/test/node-unit/cli/config.spec.js +++ b/test/node-unit/cli/config.spec.js @@ -3,18 +3,18 @@ const sinon = require('sinon'); const rewiremock = require('rewiremock/node'); -describe('cli/config', function() { +describe('cli/config', function () { const phonyConfigObject = {ok: true}; - afterEach(function() { + afterEach(function () { sinon.restore(); }); - describe('loadConfig()', function() { + describe('loadConfig()', function () { let parsers; let loadConfig; - beforeEach(function() { + beforeEach(function () { const config = rewiremock.proxy( require.resolve('../../../lib/cli/config') ); @@ -22,17 +22,17 @@ describe('cli/config', function() { loadConfig = config.loadConfig; }); - describe('when parsing succeeds', function() { - beforeEach(function() { + describe('when parsing succeeds', function () { + beforeEach(function () { sinon.stub(parsers, 'yaml').returns(phonyConfigObject); sinon.stub(parsers, 'json').returns(phonyConfigObject); sinon.stub(parsers, 'js').returns(phonyConfigObject); }); - describe('when supplied a filepath with ".yaml" extension', function() { + describe('when supplied a filepath with ".yaml" extension', function () { const filepath = 'foo.yaml'; - it('should use the YAML parser', function() { + it('should use the YAML parser', function () { loadConfig(filepath); expect(parsers.yaml, 'to have calls satisfying', [ {args: [filepath], returned: phonyConfigObject} @@ -40,10 +40,10 @@ describe('cli/config', function() { }); }); - describe('when supplied a filepath with ".yml" extension', function() { + describe('when supplied a filepath with ".yml" extension', function () { const filepath = 'foo.yml'; - it('should use the YAML parser', function() { + it('should use the YAML parser', function () { loadConfig(filepath); expect(parsers.yaml, 'to have calls satisfying', [ {args: [filepath], returned: phonyConfigObject} @@ -51,10 +51,10 @@ describe('cli/config', function() { }); }); - describe('when supplied a filepath with ".js" extension', function() { + describe('when supplied a filepath with ".js" extension', function () { const filepath = 'foo.js'; - it('should use the JS parser', function() { + it('should use the JS parser', function () { loadConfig(filepath); expect(parsers.js, 'to have calls satisfying', [ {args: [filepath], returned: phonyConfigObject} @@ -62,10 +62,10 @@ describe('cli/config', function() { }); }); - describe('when supplied a filepath with ".cjs" extension', function() { + describe('when supplied a filepath with ".cjs" extension', function () { const filepath = 'foo.cjs'; - it('should use the JS parser', function() { + it('should use the JS parser', function () { loadConfig(filepath); expect(parsers.js, 'to have calls satisfying', [ {args: [filepath], returned: phonyConfigObject} @@ -73,10 +73,10 @@ describe('cli/config', function() { }); }); - describe('when supplied a filepath with ".jsonc" extension', function() { + describe('when supplied a filepath with ".jsonc" extension', function () { const filepath = 'foo.jsonc'; - it('should use the JSON parser', function() { + it('should use the JSON parser', function () { loadConfig('foo.jsonc'); expect(parsers.json, 'to have calls satisfying', [ {args: [filepath], returned: phonyConfigObject} @@ -84,10 +84,10 @@ describe('cli/config', function() { }); }); - describe('when supplied a filepath with ".json" extension', function() { + describe('when supplied a filepath with ".json" extension', function () { const filepath = 'foo.json'; - it('should use the JSON parser', function() { + it('should use the JSON parser', function () { loadConfig('foo.json'); expect(parsers.json, 'to have calls satisfying', [ {args: [filepath], returned: phonyConfigObject} @@ -96,23 +96,23 @@ describe('cli/config', function() { }); }); - describe('when supplied a filepath with unsupported extension', function() { - beforeEach(function() { + describe('when supplied a filepath with unsupported extension', function () { + beforeEach(function () { sinon.stub(parsers, 'json').returns(phonyConfigObject); }); - it('should use the JSON parser', function() { + it('should use the JSON parser', function () { loadConfig('foo.bar'); expect(parsers.json, 'was called'); }); }); - describe('when config file parsing fails', function() { - beforeEach(function() { + describe('when config file parsing fails', function () { + beforeEach(function () { sinon.stub(parsers, 'yaml').throws('goo.yaml is unparsable'); }); - it('should throw', function() { + it('should throw', function () { expect( () => loadConfig('goo.yaml'), 'to throw', @@ -122,12 +122,12 @@ describe('cli/config', function() { }); }); - describe('findConfig()', function() { + describe('findConfig()', function () { let findup; let findConfig; let CONFIG_FILES; - beforeEach(function() { + beforeEach(function () { findup = {sync: sinon.stub().returns('/some/path/.mocharc.js')}; const config = rewiremock.proxy( require.resolve('../../../lib/cli/config'), @@ -139,7 +139,7 @@ describe('cli/config', function() { CONFIG_FILES = config.CONFIG_FILES; }); - it('should look for one of the config files using findup-sync', function() { + it('should look for one of the config files using findup-sync', function () { findConfig(); expect(findup, 'to have a call satisfying', { args: [CONFIG_FILES, {cwd: process.cwd()}], @@ -147,7 +147,7 @@ describe('cli/config', function() { }); }); - it('should support an explicit `cwd`', function() { + it('should support an explicit `cwd`', function () { findConfig('/some/path/'); expect(findup, 'to have a call satisfying', { args: [CONFIG_FILES, {cwd: '/some/path/'}], diff --git a/test/node-unit/cli/node-flags.spec.js b/test/node-unit/cli/node-flags.spec.js index 627a90378f..828a8a93c8 100644 --- a/test/node-unit/cli/node-flags.spec.js +++ b/test/node-unit/cli/node-flags.spec.js @@ -9,74 +9,74 @@ const { const {isMochaFlag} = require('../../../lib/cli/run-option-metadata'); -describe('node-flags', function() { - describe('isNodeFlag()', function() { - describe('for all allowed node environment flags', function() { +describe('node-flags', function () { + describe('isNodeFlag()', function () { + describe('for all allowed node environment flags', function () { nodeEnvFlags .filter(flag => !isMochaFlag(flag)) .forEach(envFlag => { - it(`${envFlag} should return true`, function() { + it(`${envFlag} should return true`, function () { expect(isNodeFlag(envFlag), 'to be true'); }); }); }); - describe('for all allowed node env flags which conflict with mocha flags', function() { + describe('for all allowed node env flags which conflict with mocha flags', function () { nodeEnvFlags .filter(flag => isMochaFlag(flag)) .forEach(envFlag => { - it(`${envFlag} should return false`, function() { + it(`${envFlag} should return false`, function () { expect(isNodeFlag(envFlag), 'to be false'); }); }); }); - describe('when expecting leading dashes', function() { - it('should require leading dashes', function() { + describe('when expecting leading dashes', function () { + it('should require leading dashes', function () { expect(isNodeFlag('throw-deprecation', false), 'to be false'); expect(isNodeFlag('--throw-deprecation', false), 'to be true'); }); }); - describe('special cases', function() { - it('should return true for flags starting with "preserve-symlinks"', function() { + describe('special cases', function () { + it('should return true for flags starting with "preserve-symlinks"', function () { expect(isNodeFlag('preserve-symlinks'), 'to be true'); expect(isNodeFlag('preserve-symlinks-main'), 'to be true'); expect(isNodeFlag('preserve_symlinks'), 'to be true'); }); - it('should return true for flags starting with "harmony-" or "harmony_"', function() { + it('should return true for flags starting with "harmony-" or "harmony_"', function () { expect(isNodeFlag('harmony-literally-anything'), 'to be true'); expect(isNodeFlag('harmony_literally_underscores'), 'to be true'); expect(isNodeFlag('harmonynope'), 'to be false'); }); - it('should return true for flags starting with "trace-" or "trace_"', function() { + it('should return true for flags starting with "trace-" or "trace_"', function () { expect(isNodeFlag('trace-literally-anything'), 'to be true'); expect(isNodeFlag('trace_literally_underscores'), 'to be true'); expect(isNodeFlag('tracenope'), 'to be false'); }); - it('should return true for "harmony" itself', function() { + it('should return true for "harmony" itself', function () { expect(isNodeFlag('harmony'), 'to be true'); }); - it('should return true for "gc-global"', function() { + it('should return true for "gc-global"', function () { expect(isNodeFlag('gc-global'), 'to be true'); expect(isNodeFlag('gc_global'), 'to be true'); }); - it('should return true for "es-staging"', function() { + it('should return true for "es-staging"', function () { expect(isNodeFlag('es-staging'), 'to be true'); expect(isNodeFlag('es_staging'), 'to be true'); }); - it('should return true for "use-strict"', function() { + it('should return true for "use-strict"', function () { expect(isNodeFlag('use-strict'), 'to be true'); expect(isNodeFlag('use_strict'), 'to be true'); }); - it('should return true for flags starting with "--v8-"', function() { + it('should return true for flags starting with "--v8-"', function () { expect(isNodeFlag('v8-'), 'to be false'); expect(isNodeFlag('v8-options'), 'to be false'); expect(isNodeFlag('v8_options'), 'to be false'); @@ -86,15 +86,15 @@ describe('node-flags', function() { }); }); - describe('impliesNoTimeouts()', function() { - it('should return true for inspect flags', function() { + describe('impliesNoTimeouts()', function () { + it('should return true for inspect flags', function () { expect(impliesNoTimeouts('inspect'), 'to be true'); expect(impliesNoTimeouts('inspect-brk'), 'to be true'); }); }); - describe('unparseNodeFlags()', function() { - it('should handle single v8 flags', function() { + describe('unparseNodeFlags()', function () { + it('should handle single v8 flags', function () { expect(unparseNodeFlags({'v8-numeric': 100}), 'to equal', [ '--v8-numeric=100' ]); @@ -103,7 +103,7 @@ describe('node-flags', function() { ]); }); - it('should handle multiple v8 flags', function() { + it('should handle multiple v8 flags', function () { expect( unparseNodeFlags({'v8-numeric-one': 1, 'v8-numeric-two': 2}), 'to equal', diff --git a/test/node-unit/cli/options.spec.js b/test/node-unit/cli/options.spec.js index 0455be0aa5..0508514cdd 100644 --- a/test/node-unit/cli/options.spec.js +++ b/test/node-unit/cli/options.spec.js @@ -28,14 +28,14 @@ const defaults = { extension: ['js'] }; -describe('options', function() { +describe('options', function () { let readFileSync; let findupSync; let loadOptions; let findConfig; let loadConfig; - afterEach(function() { + afterEach(function () { sinon.restore(); }); @@ -46,9 +46,9 @@ describe('options', function() { * 3. `mocha` prop of `package.json` * 4. default rc */ - describe('loadOptions()', function() { - describe('when no parameter provided', function() { - beforeEach(function() { + describe('loadOptions()', function () { + describe('when no parameter provided', function () { + beforeEach(function () { this.timeout(1000); readFileSync = sinon.stub(); readFileSync.onFirstCall().returns('{}'); @@ -64,7 +64,7 @@ describe('options', function() { }); }); - it('should return an object containing positional args, defaults, and anti-reloading flags', function() { + it('should return an object containing positional args, defaults, and anti-reloading flags', function () { expect( loadOptions(), 'to equal', @@ -77,12 +77,12 @@ describe('options', function() { }); }); - describe('when parameter provided', function() { - describe('package.json', function() { - describe('when path to package.json (`--package `) is valid', function() { + describe('when parameter provided', function () { + describe('package.json', function () { + describe('when path to package.json (`--package `) is valid', function () { let result; - beforeEach(function() { + beforeEach(function () { const filepath = '/some/package.json'; readFileSync = sinon.stub(); // package.json @@ -99,7 +99,7 @@ describe('options', function() { result = loadOptions(['--package', filepath]); }); - it('should return merged options incl. package.json opts', function() { + it('should return merged options incl. package.json opts', function () { expect( result, 'to equal', @@ -117,17 +117,17 @@ describe('options', function() { ); }); - it('should not try to find a package.json', function() { + it('should not try to find a package.json', function () { expect(findupSync, 'was not called'); }); - it('should set package = false', function() { + it('should set package = false', function () { expect(result, 'to have property', 'package', false); }); }); - describe('when path to package.json (`--package `) is invalid', function() { - beforeEach(function() { + describe('when path to package.json (`--package `) is invalid', function () { + beforeEach(function () { readFileSync = sinon.stub(); // package.json readFileSync.onFirstCall().throws('bad file message'); @@ -142,7 +142,7 @@ describe('options', function() { }); }); - it('should throw', function() { + it('should throw', function () { expect( () => { loadOptions('--package /something/wherever --require butts'); @@ -153,10 +153,10 @@ describe('options', function() { }); }); - describe('when path to package.json unspecified', function() { + describe('when path to package.json unspecified', function () { let result; - beforeEach(function() { + beforeEach(function () { const filepath = '/some/package.json'; readFileSync = sinon.stub(); // package.json @@ -175,7 +175,7 @@ describe('options', function() { result = loadOptions(); }); - it('should return merged options incl. found package.json', function() { + it('should return merged options incl. found package.json', function () { expect( result, 'to equal', @@ -193,14 +193,14 @@ describe('options', function() { ); }); - it('should set package = false', function() { + it('should set package = false', function () { expect(result, 'to have property', 'package', false); }); }); - describe('when called with package = false (`--no-package`)', function() { + describe('when called with package = false (`--no-package`)', function () { let result; - beforeEach(function() { + beforeEach(function () { readFileSync = sinon.stub(); readFileSync.onFirstCall().returns('{}'); findConfig = sinon.stub().returns('/some/path/to/.mocharc.json'); @@ -217,7 +217,7 @@ describe('options', function() { result = loadOptions('--no-diff --no-package'); }); - it('should return parsed args and default config', function() { + it('should return parsed args and default config', function () { expect( result, 'to equal', @@ -230,20 +230,20 @@ describe('options', function() { ); }); - it('should not look for package.json', function() { + it('should not look for package.json', function () { expect(findupSync, 'was not called'); }); - it('should set package = false', function() { + it('should set package = false', function () { expect(result, 'to have property', 'package', false); }); }); }); - describe('rc file', function() { - describe('when called with config = false (`--no-config`)', function() { + describe('rc file', function () { + describe('when called with config = false (`--no-config`)', function () { let result; - beforeEach(function() { + beforeEach(function () { readFileSync = sinon.stub(); readFileSync .onFirstCall() @@ -264,7 +264,7 @@ describe('options', function() { result = loadOptions('--no-diff --no-config'); }); - it('should return parsed args, default config and package.json', function() { + it('should return parsed args, default config and package.json', function () { expect( result, 'to equal', @@ -277,23 +277,23 @@ describe('options', function() { ); }); - it('should not attempt to load a config file', function() { + it('should not attempt to load a config file', function () { expect(loadConfig, 'was not called'); }); - it('should not attempt to find a config file', function() { + it('should not attempt to find a config file', function () { expect(findConfig, 'was not called'); }); - it('should set config = false', function() { + it('should set config = false', function () { expect(loadOptions(), 'to have property', 'config', false); }); }); - describe('when path to config (`--config `) is invalid', function() { + describe('when path to config (`--config `) is invalid', function () { let config; - beforeEach(function() { + beforeEach(function () { readFileSync = sinon.stub(); config = '/some/.mocharc.json'; readFileSync.onFirstCall().returns('{}'); @@ -309,21 +309,21 @@ describe('options', function() { }); }); - it('should not look for a config', function() { + it('should not look for a config', function () { try { loadOptions(`--config ${config}`); } catch (ignored) {} expect(findConfig, 'was not called'); }); - it('should attempt to load file at path', function() { + it('should attempt to load file at path', function () { try { loadOptions(`--config ${config}`); } catch (ignored) {} expect(loadConfig, 'to have a call satisfying', [config]); }); - it('should throw to warn the user', function() { + it('should throw to warn the user', function () { expect( () => { loadOptions(`--config ${config}`); @@ -334,11 +334,11 @@ describe('options', function() { }); }); - describe('when called with unspecified config', function() { - describe('when an rc file would be found', function() { + describe('when called with unspecified config', function () { + describe('when an rc file would be found', function () { let result; - beforeEach(function() { + beforeEach(function () { readFileSync = sinon.stub(); readFileSync.onFirstCall().returns('{}'); readFileSync.onSecondCall().throws(); @@ -356,25 +356,25 @@ describe('options', function() { result = loadOptions(); }); - it('should look for a config', function() { + it('should look for a config', function () { expect(findConfig, 'was called'); }); - it('should attempt to load file at found path', function() { + it('should attempt to load file at found path', function () { expect(loadConfig, 'to have a call satisfying', [ '/some/.mocharc.json' ]); }); - it('should set config = false', function() { + it('should set config = false', function () { expect(result, 'to have property', 'config', false); }); }); - describe('when an rc file would not be found', function() { + describe('when an rc file would not be found', function () { let result; - beforeEach(function() { + beforeEach(function () { readFileSync = sinon.stub(); readFileSync.onFirstCall().returns('{}'); readFileSync.onSecondCall().throws(); @@ -392,15 +392,15 @@ describe('options', function() { result = loadOptions(); }); - it('should look for a config', function() { + it('should look for a config', function () { expect(findConfig, 'was called'); }); - it('should not attempt to load a config file', function() { + it('should not attempt to load a config file', function () { expect(loadConfig, 'was not called'); }); - it('should set config = false', function() { + it('should set config = false', function () { expect(result, 'to have property', 'config', false); }); }); @@ -408,8 +408,8 @@ describe('options', function() { }); }); - describe('config priority', function() { - it('should prioritize package.json over defaults', function() { + describe('config priority', function () { + it('should prioritize package.json over defaults', function () { readFileSync = sinon.stub(); readFileSync .onFirstCall() @@ -434,7 +434,7 @@ describe('options', function() { }); }); - it('should prioritize rc file over package.json', function() { + it('should prioritize rc file over package.json', function () { readFileSync = sinon.stub(); readFileSync.onFirstCall().returns('{"mocha": {"timeout": 700}}'); readFileSync.onSecondCall().returns('--timeout 800'); @@ -452,7 +452,7 @@ describe('options', function() { expect(loadOptions(), 'to have property', 'timeout', 600); }); - it('should prioritize args over rc file', function() { + it('should prioritize args over rc file', function () { readFileSync = sinon.stub(); readFileSync.onFirstCall().returns('{"mocha": {"timeout": 700}}'); readFileSync.onSecondCall().returns('--timeout 800'); @@ -476,8 +476,8 @@ describe('options', function() { }); }); - describe('when called with a one-and-done arg', function() { - beforeEach(function() { + describe('when called with a one-and-done arg', function () { + beforeEach(function () { readFileSync = sinon.stub(); findConfig = sinon.stub(); loadConfig = sinon.stub(); @@ -491,19 +491,19 @@ describe('options', function() { }); ONE_AND_DONE_ARGS.forEach(arg => { - describe(`"${arg}"`, function() { - it(`should return basic parsed arguments and flag`, function() { + describe(`"${arg}"`, function () { + it(`should return basic parsed arguments and flag`, function () { expect(loadOptions(`--${arg}`), 'to equal', {_: [], [arg]: true}); }); }); }); }); - describe('"extension" handling', function() { - describe('when user supplies "extension" option', function() { + describe('"extension" handling', function () { + describe('when user supplies "extension" option', function () { let result; - beforeEach(function() { + beforeEach(function () { readFileSync = sinon.stub(); readFileSync.onFirstCall().throws(); findConfig = sinon.stub().returns('/some/.mocharc.json'); @@ -518,15 +518,15 @@ describe('options', function() { result = loadOptions(['--extension', 'ts']); }); - it('should not concatenate the default value', function() { + it('should not concatenate the default value', function () { expect(result, 'to have property', 'extension', ['ts', 'tsx']); }); }); - describe('when user does not supply "extension" option', function() { + describe('when user does not supply "extension" option', function () { let result; - beforeEach(function() { + beforeEach(function () { readFileSync = sinon.stub(); readFileSync.onFirstCall().throws(); findConfig = sinon.stub().returns('/some/.mocharc.json'); @@ -541,17 +541,17 @@ describe('options', function() { result = loadOptions(); }); - it('should retain the default', function() { + it('should retain the default', function () { expect(result, 'to have property', 'extension', ['js']); }); }); }); - describe('"spec" handling', function() { - describe('when user supplies "spec" in config and positional arguments', function() { + describe('"spec" handling', function () { + describe('when user supplies "spec" in config and positional arguments', function () { let result; - beforeEach(function() { + beforeEach(function () { readFileSync = sinon.stub(); readFileSync.onFirstCall().throws(); findConfig = sinon.stub().returns('/some/.mocharc.json'); @@ -566,7 +566,7 @@ describe('options', function() { result = loadOptions(['*.test.js']); }); - it('should place both - unsplitted - into the positional arguments array', function() { + it('should place both - unsplitted - into the positional arguments array', function () { expect(result, 'to have property', '_', [ '*.test.js', '{dirA,dirB}/**/*.spec.js' @@ -575,10 +575,10 @@ describe('options', function() { }); }); - describe('"ignore" handling', function() { + describe('"ignore" handling', function () { let result; - beforeEach(function() { + beforeEach(function () { readFileSync = sinon.stub(); readFileSync.onFirstCall().throws(); findConfig = sinon.stub().returns('/some/.mocharc.json'); @@ -593,7 +593,7 @@ describe('options', function() { result = loadOptions(['--ignore', '*.test.js']); }); - it('should not split option values by comma', function() { + it('should not split option values by comma', function () { expect(result, 'to have property', 'ignore', [ '*.test.js', '{dirA,dirB}/**/*.spec.js' diff --git a/test/node-unit/cli/run-helpers.spec.js b/test/node-unit/cli/run-helpers.spec.js index 9c3f60ee8a..4ad650f21d 100644 --- a/test/node-unit/cli/run-helpers.spec.js +++ b/test/node-unit/cli/run-helpers.spec.js @@ -3,10 +3,10 @@ const {validateLegacyPlugin, list} = require('../../../lib/cli/run-helpers'); const Mocha = require('../../../lib/mocha'); -describe('helpers', function() { - describe('validateLegacyPlugin()', function() { - describe('when used with "reporter" key', function() { - it('should disallow an array of names', function() { +describe('helpers', function () { + describe('validateLegacyPlugin()', function () { + describe('when used with "reporter" key', function () { + it('should disallow an array of names', function () { expect( () => validateLegacyPlugin({reporter: ['bar']}, 'reporter'), 'to throw', @@ -17,7 +17,7 @@ describe('helpers', function() { ); }); - it('should fail to recognize an unknown reporter', function() { + it('should fail to recognize an unknown reporter', function () { expect( () => validateLegacyPlugin({reporter: 'bar'}, 'reporter'), 'to throw', @@ -26,15 +26,15 @@ describe('helpers', function() { }); }); - describe('when used with an "ui" key', function() { - it('should disallow an array of names', function() { + describe('when used with an "ui" key', function () { + it('should disallow an array of names', function () { expect(() => validateLegacyPlugin({ui: ['bar']}, 'ui'), 'to throw', { code: 'ERR_MOCHA_INVALID_INTERFACE', message: /can only be specified once/i }); }); - it('should fail to recognize an unknown interface', function() { + it('should fail to recognize an unknown interface', function () { expect(() => validateLegacyPlugin({ui: 'bar'}, 'ui'), 'to throw', { code: 'ERR_MOCHA_INVALID_INTERFACE', message: /cannot find module/i @@ -42,8 +42,8 @@ describe('helpers', function() { }); }); - describe('when used with an unknown plugin type', function() { - it('should fail', function() { + describe('when used with an unknown plugin type', function () { + it('should fail', function () { expect( () => validateLegacyPlugin({frog: 'bar'}, 'frog'), 'to throw', @@ -52,8 +52,8 @@ describe('helpers', function() { }); }); - describe('when used with a third-party interface', function() { - it('should add the interface to "Mocha.interfaces"', function() { + describe('when used with a third-party interface', function () { + it('should add the interface to "Mocha.interfaces"', function () { // let's suppose that `glob` is an interface const opts = {ui: 'glob'}; validateLegacyPlugin(opts, 'ui', Mocha.interfaces); @@ -63,8 +63,8 @@ describe('helpers', function() { }); }); - describe('when a plugin throws an exception upon load', function() { - it('should fail and report the original error', function() { + describe('when a plugin throws an exception upon load', function () { + it('should fail and report the original error', function () { expect( () => validateLegacyPlugin( @@ -80,14 +80,14 @@ describe('helpers', function() { }); }); - describe('list()', function() { - describe('when provided a flat array', function() { - it('should return a flat array', function() { + describe('list()', function () { + describe('when provided a flat array', function () { + it('should return a flat array', function () { expect(list(['foo', 'bar']), 'to equal', ['foo', 'bar']); }); }); - describe('when provided a nested array', function() { - it('should return a flat array', function() { + describe('when provided a nested array', function () { + it('should return a flat array', function () { expect(list([['foo', 'bar'], 'baz']), 'to equal', [ 'foo', 'bar', @@ -95,8 +95,8 @@ describe('helpers', function() { ]); }); }); - describe('when given a comma-delimited string', function() { - it('should return a flat array', function() { + describe('when given a comma-delimited string', function () { + it('should return a flat array', function () { expect(list('foo,bar'), 'to equal', ['foo', 'bar']); }); }); diff --git a/test/node-unit/cli/run.spec.js b/test/node-unit/cli/run.spec.js index ed93b09129..2c97e16862 100644 --- a/test/node-unit/cli/run.spec.js +++ b/test/node-unit/cli/run.spec.js @@ -3,16 +3,16 @@ const {builder} = require('../../../lib/cli/run'); const {types} = require('../../../lib/cli/run-option-metadata'); -describe('command', function() { - describe('run', function() { - describe('builder', function() { +describe('command', function () { + describe('run', function () { + describe('builder', function () { const IGNORED_OPTIONS = new Set(['help', 'version']); const options = builder(require('yargs/yargs')().reset()).getOptions(); ['number', 'string', 'boolean', 'array'].forEach(type => { - describe(`${type} type`, function() { + describe(`${type} type`, function () { Array.from(new Set(options[type])).forEach(option => { if (!IGNORED_OPTIONS.has(option)) { - it(`should include option ${option}`, function() { + it(`should include option ${option}`, function () { expect(types[type], 'to contain', option); }); } diff --git a/test/node-unit/mocha.spec.js b/test/node-unit/mocha.spec.js index 49ae903728..8a30adb5d2 100644 --- a/test/node-unit/mocha.spec.js +++ b/test/node-unit/mocha.spec.js @@ -10,12 +10,12 @@ const DUMBER_FIXTURE_PATH = require.resolve( './fixtures/dumber-module.fixture.js' ); -describe('Mocha', function() { +describe('Mocha', function () { let stubs; let opts; let Mocha; - beforeEach(function() { + beforeEach(function () { opts = {reporter: sinon.stub()}; stubs = {}; @@ -74,33 +74,33 @@ describe('Mocha', function() { delete require.cache[DUMBER_FIXTURE_PATH]; }); - afterEach(function() { + afterEach(function () { delete require.cache[DUMB_FIXTURE_PATH]; delete require.cache[DUMBER_FIXTURE_PATH]; sinon.restore(); }); - describe('instance method', function() { + describe('instance method', function () { let mocha; - beforeEach(function() { + beforeEach(function () { mocha = new Mocha(opts); }); - describe('parallelMode()', function() { - describe('when `Mocha` is running in Node.js', function() { - it('should return the Mocha instance', function() { + describe('parallelMode()', function () { + describe('when `Mocha` is running in Node.js', function () { + it('should return the Mocha instance', function () { expect(mocha.parallelMode(), 'to be', mocha); }); - describe('when parallel mode is already enabled', function() { - beforeEach(function() { + describe('when parallel mode is already enabled', function () { + beforeEach(function () { mocha.options.parallel = true; mocha._runnerClass = stubs.ParallelBufferedRunner; mocha._lazyLoadFiles = true; }); - it('should not swap the Runner, nor change lazy loading setting', function() { + it('should not swap the Runner, nor change lazy loading setting', function () { expect(mocha.parallelMode(true), 'to satisfy', { options: {parallel: true}, _runnerClass: stubs.ParallelBufferedRunner, @@ -109,14 +109,14 @@ describe('Mocha', function() { }); }); - describe('when parallel mode is already disabled', function() { - beforeEach(function() { + describe('when parallel mode is already disabled', function () { + beforeEach(function () { mocha.options.parallel = false; mocha._runnerClass = Mocha.Runner; mocha._lazyLoadFiles = false; }); - it('should not swap the Runner, nor change lazy loading setting', function() { + it('should not swap the Runner, nor change lazy loading setting', function () { expect(mocha.parallelMode(false), 'to satisfy', { options: {parallel: false}, _runnerClass: Mocha.Runner, @@ -125,18 +125,18 @@ describe('Mocha', function() { }); }); - describe('when `Mocha` instance in serial mode', function() { - beforeEach(function() { + describe('when `Mocha` instance in serial mode', function () { + beforeEach(function () { mocha.options.parallel = false; }); - describe('when passed `true` value', function() { - describe('when `Mocha` instance is in `INIT` state', function() { - beforeEach(function() { + describe('when passed `true` value', function () { + describe('when `Mocha` instance is in `INIT` state', function () { + beforeEach(function () { mocha._state = 'init'; }); - it('should enable parallel mode', function() { + it('should enable parallel mode', function () { // FIXME: the dynamic require() call breaks the mock of // `ParallelBufferedRunner` and returns the real class. // don't know how to make this work or if it's even possible @@ -150,12 +150,12 @@ describe('Mocha', function() { }); }); - describe('when `Mocha` instance is not in `INIT` state', function() { - beforeEach(function() { + describe('when `Mocha` instance is not in `INIT` state', function () { + beforeEach(function () { mocha._state = 'disposed'; }); - it('should throw', function() { + it('should throw', function () { expect( () => { mocha.parallelMode(true); @@ -169,13 +169,13 @@ describe('Mocha', function() { }); }); - describe('when passed non-`true` value', function() { - describe('when `Mocha` instance is in `INIT` state', function() { - beforeEach(function() { + describe('when passed non-`true` value', function () { + describe('when `Mocha` instance is in `INIT` state', function () { + beforeEach(function () { mocha._state = 'init'; }); - it('should enable serial mode', function() { + it('should enable serial mode', function () { expect(mocha.parallelMode(0), 'to satisfy', { _runnerClass: Mocha.Runner, options: { @@ -190,19 +190,19 @@ describe('Mocha', function() { }); }); - describe('addFile()', function() { - it('should add the given file to the files array', function() { + describe('addFile()', function () { + it('should add the given file to the files array', function () { mocha.addFile('some-file.js'); expect(mocha.files, 'to exhaustively satisfy', ['some-file.js']); }); - it('should be chainable', function() { + it('should be chainable', function () { expect(mocha.addFile('some-file.js'), 'to be', mocha); }); }); - describe('loadFiles()', function() { - it('should load all files from the files array', function() { + describe('loadFiles()', function () { + it('should load all files from the files array', function () { this.timeout(1000); mocha.files = [DUMB_FIXTURE_PATH, DUMBER_FIXTURE_PATH]; mocha.loadFiles(); @@ -212,15 +212,15 @@ describe('Mocha', function() { ]); }); - it('should execute the optional callback if given', function() { + it('should execute the optional callback if given', function () { expect(cb => { mocha.loadFiles(cb); }, 'to call the callback'); }); }); - describe('unloadFiles()', function() { - it('should delegate Mocha.unloadFile() for each item in its list of files', function() { + describe('unloadFiles()', function () { + it('should delegate Mocha.unloadFile() for each item in its list of files', function () { mocha.files = [DUMB_FIXTURE_PATH, DUMBER_FIXTURE_PATH]; sinon.stub(Mocha, 'unloadFile'); mocha.unloadFiles(); @@ -231,29 +231,29 @@ describe('Mocha', function() { .and('was called twice'); }); - it('should be chainable', function() { + it('should be chainable', function () { expect(mocha.unloadFiles(), 'to be', mocha); }); }); - describe('reporter()', function() { - describe('when a reporter exists relative to the cwd', function() { - beforeEach(function() { + describe('reporter()', function () { + describe('when a reporter exists relative to the cwd', function () { + beforeEach(function () { stubs.utils.cwd.returns( path.resolve(__dirname, '..', '..', 'lib', 'reporters') ); }); - it('should load from current working directory', function() { - expect(function() { + it('should load from current working directory', function () { + expect(function () { mocha.reporter('./spec.js'); }, 'not to throw'); }); - describe('when the reporter throws upon load', function() { - it('should throw "invalid reporter" exception', function() { + describe('when the reporter throws upon load', function () { + it('should throw "invalid reporter" exception', function () { expect( - function() { + function () { mocha.reporter( '../../test/node-unit/fixtures/wonky-reporter.fixture.js' ); @@ -265,7 +265,7 @@ describe('Mocha', function() { ); }); - it('should warn about the error before throwing', function() { + it('should warn about the error before throwing', function () { try { mocha.reporter( '../../test/node-unit/fixtures/wonky-reporter.fixture.js' @@ -280,17 +280,17 @@ describe('Mocha', function() { }); }); - describe('when a reporter exists relative to the "mocha" module path', function() { - it('should load from module path', function() { - expect(function() { + describe('when a reporter exists relative to the "mocha" module path', function () { + it('should load from module path', function () { + expect(function () { mocha.reporter('./reporters/spec'); }, 'not to throw'); }); - describe('when the reporter throws upon load', function() { - it('should throw "invalid reporter" exception', function() { + describe('when the reporter throws upon load', function () { + it('should throw "invalid reporter" exception', function () { expect( - function() { + function () { mocha.reporter( './test/node-unit/fixtures/wonky-reporter.fixture.js' ); @@ -302,7 +302,7 @@ describe('Mocha', function() { ); }); - it('should warn about the error before throwing', function() { + it('should warn about the error before throwing', function () { try { mocha.reporter( './test/node-unit/fixtures/wonky-reporter.fixture.js' @@ -318,18 +318,18 @@ describe('Mocha', function() { }); }); - describe('unloadFiles()', function() { - it('should reset referencesCleaned and allow for next run', function(done) { - mocha.run(function() { + describe('unloadFiles()', function () { + it('should reset referencesCleaned and allow for next run', function (done) { + mocha.run(function () { mocha.unloadFiles(); mocha.run(done); }); }); - it('should not be allowed when the current instance is already disposed', function() { + it('should not be allowed when the current instance is already disposed', function () { mocha.dispose(); expect( - function() { + function () { mocha.unloadFiles(); }, 'to throw', @@ -338,19 +338,19 @@ describe('Mocha', function() { }); }); - describe('lazyLoadFiles()', function() { - it('should return the `Mocha` instance', function() { + describe('lazyLoadFiles()', function () { + it('should return the `Mocha` instance', function () { expect(mocha.lazyLoadFiles(), 'to be', mocha); }); - describe('when passed a non-`true` value', function() { - it('should enable eager loading', function() { + describe('when passed a non-`true` value', function () { + it('should enable eager loading', function () { mocha.lazyLoadFiles(0); expect(mocha._lazyLoadFiles, 'to be false'); }); }); - describe('when passed `true`', function() { - it('should enable lazy loading', function() { + describe('when passed `true`', function () { + it('should enable lazy loading', function () { mocha.lazyLoadFiles(true); expect(mocha._lazyLoadFiles, 'to be true'); }); @@ -358,9 +358,9 @@ describe('Mocha', function() { }); }); - describe('static method', function() { - describe('unloadFile()', function() { - it('should unload a specific file from cache', function() { + describe('static method', function () { + describe('unloadFile()', function () { + it('should unload a specific file from cache', function () { require(DUMB_FIXTURE_PATH); Mocha.unloadFile(DUMB_FIXTURE_PATH); expect(require.cache, 'not to have key', DUMB_FIXTURE_PATH); diff --git a/test/node-unit/parallel-buffered-runner.spec.js b/test/node-unit/parallel-buffered-runner.spec.js index 1d5739343b..5d0a64b770 100644 --- a/test/node-unit/parallel-buffered-runner.spec.js +++ b/test/node-unit/parallel-buffered-runner.spec.js @@ -14,8 +14,8 @@ const sinon = require('sinon'); const {constants} = require('../../lib/utils'); const {MOCHA_ID_PROP_NAME} = constants; -describe('parallel-buffered-runner', function() { - describe('ParallelBufferedRunner', function() { +describe('parallel-buffered-runner', function () { + describe('ParallelBufferedRunner', function () { let run; let BufferedWorkerPool; let terminate; @@ -24,7 +24,7 @@ describe('parallel-buffered-runner', function() { let warn; let fatalError; - beforeEach(function() { + beforeEach(function () { suite = new Suite('a root suite', {}, true); warn = sinon.stub(); @@ -59,8 +59,8 @@ describe('parallel-buffered-runner', function() { ); }); - describe('constructor', function() { - it('should start in "IDLE" state', function() { + describe('constructor', function () { + it('should start in "IDLE" state', function () { expect( new ParallelBufferedRunner(suite), 'to have property', @@ -70,15 +70,15 @@ describe('parallel-buffered-runner', function() { }); }); - describe('instance property', function() { + describe('instance property', function () { let runner; - beforeEach(function() { + beforeEach(function () { runner = new ParallelBufferedRunner(suite); }); - describe('_state', function() { - it('should disallow an invalid state transition', function() { + describe('_state', function () { + it('should disallow an invalid state transition', function () { expect( () => { runner._state = 'BAILED'; @@ -90,15 +90,15 @@ describe('parallel-buffered-runner', function() { }); }); - describe('event', function() { + describe('event', function () { let runner; - beforeEach(function() { + beforeEach(function () { runner = new ParallelBufferedRunner(suite); }); - describe('EVENT_RUN_END', function() { - it('should change the state to COMPLETE', function() { + describe('EVENT_RUN_END', function () { + it('should change the state to COMPLETE', function () { runner._state = 'RUNNING'; runner.emit(Runner.constants.EVENT_RUN_END); expect(runner._state, 'to be', 'COMPLETE'); @@ -106,21 +106,21 @@ describe('parallel-buffered-runner', function() { }); }); - describe('instance method', function() { - describe('run()', function() { + describe('instance method', function () { + describe('run()', function () { let runner; - beforeEach(function() { + beforeEach(function () { runner = new ParallelBufferedRunner(suite); }); // the purpose of this is to ensure that--despite using `Promise`s // internally--`BufferedRunner#run` does not return a `Promise`. - it('should be chainable', function(done) { + it('should be chainable', function (done) { expect(runner.run(done, {files: [], options: {}}), 'to be', runner); }); - it('should emit `EVENT_RUN_BEGIN`', async function() { + it('should emit `EVENT_RUN_BEGIN`', async function () { return expect( () => new Promise(resolve => { @@ -132,12 +132,12 @@ describe('parallel-buffered-runner', function() { ); }); - describe('when instructed to link objects', function() { - beforeEach(function() { + describe('when instructed to link objects', function () { + beforeEach(function () { runner._linkPartialObjects = true; }); - it('should create object references', function() { + it('should create object references', function () { const options = {reporter: runner._workerReporter}; const someSuite = { title: 'some suite', @@ -189,8 +189,8 @@ describe('parallel-buffered-runner', function() { ); }); - describe('when event data object is missing an ID', function() { - it('should result in an uncaught exception', function(done) { + describe('when event data object is missing an ID', function () { + it('should result in an uncaught exception', function (done) { const options = {reporter: runner._workerReporter}; sinon.spy(runner, 'uncaught'); const someSuite = { @@ -238,8 +238,8 @@ describe('parallel-buffered-runner', function() { }); }); - describe('when a worker fails', function() { - it('should recover', function(done) { + describe('when a worker fails', function () { + it('should recover', function (done) { const options = {reporter: runner._workerReporter}; run.withArgs('some-file.js', options).rejects(new Error('whoops')); run.withArgs('some-other-file.js', options).resolves({ @@ -272,7 +272,7 @@ describe('parallel-buffered-runner', function() { ); }); - it('should delegate to Runner#uncaught', function(done) { + it('should delegate to Runner#uncaught', function (done) { const options = {reporter: runner._workerReporter}; sinon.spy(runner, 'uncaught'); const err = new Error('whoops'); @@ -308,9 +308,9 @@ describe('parallel-buffered-runner', function() { }); }); - describe('when suite should bail', function() { - describe('when no event contains an error', function() { - it('should not force-terminate', function(done) { + describe('when suite should bail', function () { + describe('when no event contains an error', function () { + it('should not force-terminate', function (done) { run.resolves({ failureCount: 0, events: [ @@ -352,9 +352,9 @@ describe('parallel-buffered-runner', function() { }); }); - describe('when an event contains an error and has positive failures', function() { - describe('when subsequent files have not yet been run', function() { - it('should cleanly terminate the thread pool', function(done) { + describe('when an event contains an error and has positive failures', function () { + describe('when subsequent files have not yet been run', function () { + it('should cleanly terminate the thread pool', function (done) { const options = {reporter: runner._workerReporter}; const err = { __type: 'Error', @@ -404,8 +404,8 @@ describe('parallel-buffered-runner', function() { }); }); - describe('when subsequent files already started running', function() { - it('should cleanly terminate the thread pool', function(done) { + describe('when subsequent files already started running', function () { + it('should cleanly terminate the thread pool', function (done) { const options = {reporter: runner._workerReporter}; const err = { __type: 'Error', @@ -479,9 +479,9 @@ describe('parallel-buffered-runner', function() { }); }); - describe('when a suite has a bail flag', function() { - describe('when no event contains an error', function() { - it('should not force-terminate', function(done) { + describe('when a suite has a bail flag', function () { + describe('when no event contains an error', function () { + it('should not force-terminate', function (done) { run.resolves({ failureCount: 0, events: [ @@ -516,9 +516,9 @@ describe('parallel-buffered-runner', function() { }); }); - describe('when an event contains an error and has positive failures', function() { - describe('when subsequent files have not yet been run', function() { - it('should cleanly terminate the thread pool', function(done) { + describe('when an event contains an error and has positive failures', function () { + describe('when subsequent files have not yet been run', function () { + it('should cleanly terminate the thread pool', function (done) { const options = {reporter: runner._workerReporter}; const err = { __type: 'Error', @@ -561,8 +561,8 @@ describe('parallel-buffered-runner', function() { }); }); - describe('when subsequent files already started running', function() { - it('should cleanly terminate the thread pool', function(done) { + describe('when subsequent files already started running', function () { + it('should cleanly terminate the thread pool', function (done) { const options = {reporter: runner._workerReporter}; const err = { __type: 'Error', @@ -621,8 +621,8 @@ describe('parallel-buffered-runner', function() { }); }); - describe('when subsequent files have not yet been run', function() { - it('should cleanly terminate the thread pool', function(done) { + describe('when subsequent files have not yet been run', function () { + it('should cleanly terminate the thread pool', function (done) { const options = {reporter: runner._workerReporter}; const err = { __type: 'Error', @@ -668,40 +668,40 @@ describe('parallel-buffered-runner', function() { }); }); - describe('linkPartialObjects()', function() { + describe('linkPartialObjects()', function () { let runner; - beforeEach(function() { + beforeEach(function () { runner = new ParallelBufferedRunner(suite); }); - it('should return the runner', function() { + it('should return the runner', function () { expect(runner.linkPartialObjects(), 'to be', runner); }); // avoid testing implementation details; don't check _linkPartialObjects }); - describe('isParallelMode()', function() { + describe('isParallelMode()', function () { let runner; - beforeEach(function() { + beforeEach(function () { runner = new ParallelBufferedRunner(suite); }); - it('should return true', function() { + it('should return true', function () { expect(runner.isParallelMode(), 'to be true'); }); }); - describe('workerReporter()', function() { + describe('workerReporter()', function () { let runner; - beforeEach(function() { + beforeEach(function () { runner = new ParallelBufferedRunner(suite); }); - it('should return its context', function() { + it('should return its context', function () { expect(runner.workerReporter(), 'to be', runner); }); }); diff --git a/test/node-unit/reporters/parallel-buffered.spec.js b/test/node-unit/reporters/parallel-buffered.spec.js index 91c9e4df15..24a70dd625 100644 --- a/test/node-unit/reporters/parallel-buffered.spec.js +++ b/test/node-unit/reporters/parallel-buffered.spec.js @@ -22,11 +22,11 @@ const {EventEmitter} = require('events'); const sinon = require('sinon'); const rewiremock = require('rewiremock/node'); -describe('ParallelBuffered', function() { +describe('ParallelBuffered', function () { let runner; let ParallelBuffered; - beforeEach(function() { + beforeEach(function () { runner = new EventEmitter(); ParallelBuffered = rewiremock.proxy( () => require('../../../lib/nodejs/reporters/parallel-buffered'), @@ -53,12 +53,12 @@ describe('ParallelBuffered', function() { ); }); - afterEach(function() { + afterEach(function () { sinon.restore(); }); - describe('constructor', function() { - it('should listen for Runner events', function() { + describe('constructor', function () { + it('should listen for Runner events', function () { // EventEmitter#once calls thru to EventEmitter#on, which // befouls our assertion below. sinon.stub(runner, 'once'); @@ -80,7 +80,7 @@ describe('ParallelBuffered', function() { ]); }); - it('should listen for Runner events expecting to occur once', function() { + it('should listen for Runner events expecting to occur once', function () { sinon.stub(runner, 'once'); // eslint-disable-next-line no-new new ParallelBuffered(runner); @@ -92,22 +92,22 @@ describe('ParallelBuffered', function() { }); }); - describe('event', function() { + describe('event', function () { let reporter; - beforeEach(function() { + beforeEach(function () { reporter = new ParallelBuffered(runner); }); - describe('on EVENT_RUN_END', function() { - it('should remove all listeners', function() { + describe('on EVENT_RUN_END', function () { + it('should remove all listeners', function () { runner.emit(EVENT_RUN_END); expect(runner.listeners(), 'to be empty'); }); }); - describe('on any other event listened for', function() { - it('should populate its `events` array with SerializableEvents', function() { + describe('on any other event listened for', function () { + it('should populate its `events` array with SerializableEvents', function () { const suite = { title: 'some suite' }; @@ -150,15 +150,15 @@ describe('ParallelBuffered', function() { }); }); - describe('instance method', function() { + describe('instance method', function () { let reporter; - beforeEach(function() { + beforeEach(function () { reporter = new ParallelBuffered(runner); }); - describe('done', function() { - it('should execute its callback with a SerializableWorkerResult', function() { + describe('done', function () { + it('should execute its callback with a SerializableWorkerResult', function () { const suite = { title: 'some suite' }; @@ -207,7 +207,7 @@ describe('ParallelBuffered', function() { ]); }); - it('should reset its `events` prop', function() { + it('should reset its `events` prop', function () { const suite = { title: 'some suite' }; diff --git a/test/node-unit/serializer.spec.js b/test/node-unit/serializer.spec.js index 0169338a05..cd43a17092 100644 --- a/test/node-unit/serializer.spec.js +++ b/test/node-unit/serializer.spec.js @@ -8,29 +8,29 @@ const { SerializableWorkerResult } = require('../../lib/nodejs/serializer'); -describe('serializer', function() { - afterEach(function() { +describe('serializer', function () { + afterEach(function () { sinon.restore(); }); - describe('function', function() { - describe('serialize', function() { - describe('when passed a non-object value', function() { - it('should return the value', function() { + describe('function', function () { + describe('serialize', function () { + describe('when passed a non-object value', function () { + it('should return the value', function () { expect(serialize('knees & toes'), 'to be', 'knees & toes'); }); }); - describe('when passed an object value', function() { - describe('w/o a `serialize` method', function() { - it('should return the value', function() { + describe('when passed an object value', function () { + describe('w/o a `serialize` method', function () { + it('should return the value', function () { const obj = {}; expect(serialize(obj), 'to be', obj); }); }); - describe('having a `serialize` method', function() { - it('should return the result of the `serialize` method', function() { + describe('having a `serialize` method', function () { + it('should return the result of the `serialize` method', function () { const serializedObj = {foo: 'bar'}; const obj = {serialize: sinon.stub().returns(serializedObj)}; expect(serialize(obj), 'to be', serializedObj); @@ -38,37 +38,37 @@ describe('serializer', function() { }); }); - describe('when not passed anything', function() { - it('should return `undefined`', function() { + describe('when not passed anything', function () { + it('should return `undefined`', function () { expect(serialize(), 'to be undefined'); }); }); }); - describe('deserialize', function() { - describe('when passed nothing', function() { - it('should return `undefined`', function() { + describe('deserialize', function () { + describe('when passed nothing', function () { + it('should return `undefined`', function () { expect(deserialize(), 'to be undefined'); }); }); - describe('when passed a non-object value', function() { - it('should return the value', function() { + describe('when passed a non-object value', function () { + it('should return the value', function () { expect(deserialize(500), 'to be', 500); }); }); - describe('when passed an object value which is not a SerializedWorkerResult', function() { - it('should return the value', function() { + describe('when passed an object value which is not a SerializedWorkerResult', function () { + it('should return the value', function () { const obj = {}; expect(deserialize(obj), 'to be', obj); }); }); - describe('when passed a SerializedWorkerResult object', function() { + describe('when passed a SerializedWorkerResult object', function () { // note that SerializedWorkerResult is an interface (typedef), not a class. - it('should return the result of `SerializableWorkerResult.deserialize` called on the value', function() { + it('should return the result of `SerializableWorkerResult.deserialize` called on the value', function () { const obj = Object.assign({}, SerializableWorkerResult.create()); sinon.stub(SerializableWorkerResult, 'deserialize').returns('butts'); deserialize(obj); @@ -85,18 +85,18 @@ describe('serializer', function() { }); }); - describe('SerializableEvent', function() { - describe('constructor', function() { - describe('when called without `eventName`', function() { - it('should throw "invalid arg value" error', function() { + describe('SerializableEvent', function () { + describe('constructor', function () { + describe('when called without `eventName`', function () { + it('should throw "invalid arg value" error', function () { expect(() => new SerializableEvent(), 'to throw', { code: 'ERR_MOCHA_INVALID_ARG_TYPE' }); }); }); - describe('when called with a non-object `rawObject`', function() { - it('should throw "invalid arg type" error', function() { + describe('when called with a non-object `rawObject`', function () { + it('should throw "invalid arg type" error', function () { expect(() => new SerializableEvent('blub', 'glug'), 'to throw', { code: 'ERR_MOCHA_INVALID_ARG_TYPE' }); @@ -104,22 +104,22 @@ describe('serializer', function() { }); }); - describe('instance method', function() { - describe('serialize', function() { - it('should mutate the instance in-place', function() { + describe('instance method', function () { + describe('serialize', function () { + it('should mutate the instance in-place', function () { const evt = SerializableEvent.create('foo'); expect(evt.serialize(), 'to be', evt); }); - it('should freeze the instance', function() { + it('should freeze the instance', function () { expect( Object.isFrozen(SerializableEvent.create('foo').serialize()), 'to be true' ); }); - describe('when passed an object with a `serialize` method', function() { - it('should call the `serialize` method', function() { + describe('when passed an object with a `serialize` method', function () { + it('should call the `serialize` method', function () { const obj = { serialize: sinon.stub() }; @@ -128,8 +128,8 @@ describe('serializer', function() { }); }); - describe('when passed an object containing an object with a `serialize` method', function() { - it('should call the `serialize` method', function() { + describe('when passed an object containing an object with a `serialize` method', function () { + it('should call the `serialize` method', function () { const stub = sinon.stub(); const obj = { nested: { @@ -141,8 +141,8 @@ describe('serializer', function() { }); }); - describe('when passed an object containing a non-`serialize` method', function() { - it('should remove the method', function() { + describe('when passed an object containing a non-`serialize` method', function () { + it('should remove the method', function () { const obj = { func: () => {} }; @@ -157,8 +157,8 @@ describe('serializer', function() { }); }); - describe('when passed an object containing an array', function() { - it('should serialize the array', function() { + describe('when passed an object containing an array', function () { + it('should serialize the array', function () { const obj = { list: [{herp: 'derp'}, {bing: 'bong'}] }; @@ -170,8 +170,8 @@ describe('serializer', function() { }); }); - describe('when passed an error', function() { - it('should serialize the error', function() { + describe('when passed an error', function () { + it('should serialize the error', function () { const obj = {}; const err = new Error('monkeypants'); expect( @@ -189,7 +189,7 @@ describe('serializer', function() { ); }); - it('should retain own props', function() { + it('should retain own props', function () { const obj = {}; const err = new Error('monkeypants'); err.code = 'MONKEY'; @@ -209,7 +209,7 @@ describe('serializer', function() { ); }); - it('should not retain not-own props', function() { + it('should not retain not-own props', function () { const obj = {}; const err = new Error('monkeypants'); // eslint-disable-next-line no-proto @@ -230,8 +230,8 @@ describe('serializer', function() { }); }); - describe('when passed an object containing a top-level prop with an Error value', function() { - it('should serialize the Error', function() { + describe('when passed an object containing a top-level prop with an Error value', function () { + it('should serialize the Error', function () { const obj = { monkeyError: new Error('pantsmonkey') }; @@ -248,8 +248,8 @@ describe('serializer', function() { }); }); }); - describe('when passed an object containing a nested prop with an Error value', function() { - it('should serialize the Error', function() { + describe('when passed an object containing a nested prop with an Error value', function () { + it('should serialize the Error', function () { const obj = { nestedObj: { monkeyError: new Error('pantsmonkey') @@ -273,25 +273,25 @@ describe('serializer', function() { }); }); - describe('static method', function() { - describe('deserialize', function() { - describe('when passed a falsy parameter', function() { - it('should throw "invalid arg type" error', function() { + describe('static method', function () { + describe('deserialize', function () { + describe('when passed a falsy parameter', function () { + it('should throw "invalid arg type" error', function () { expect(SerializableEvent.deserialize, 'to throw', { code: 'ERR_MOCHA_INVALID_ARG_TYPE' }); }); }); - it('should return a new object w/ null prototype', function() { + it('should return a new object w/ null prototype', function () { const obj = {bob: 'bob'}; expect(SerializableEvent.deserialize(obj), 'to satisfy', obj) .and('not to equal', obj) .and('not to have property', 'constructor'); }); - describe('when passed value contains `data` prop', function() { - it('should ignore __proto__', function() { + describe('when passed value contains `data` prop', function () { + it('should ignore __proto__', function () { const obj = { data: Object.create(null) }; @@ -304,8 +304,8 @@ describe('serializer', function() { expect(SerializableEvent.deserialize(obj), 'to equal', expected); }); - describe('when `data` prop contains a nested serialized Error prop', function() { - it('should create an Error instance from the nested serialized Error prop', function() { + describe('when `data` prop contains a nested serialized Error prop', function () { + it('should create an Error instance from the nested serialized Error prop', function () { const message = 'problems!'; const stack = 'problem instructions'; const code = 'EIEIO'; @@ -336,8 +336,8 @@ describe('serializer', function() { }); }); - describe('when passed value contains an `error` prop', function() { - it('should create an Error instance from the prop', function() { + describe('when passed value contains an `error` prop', function () { + it('should create an Error instance from the prop', function () { const message = 'problems!'; const stack = 'problem instructions'; const code = 'EIEIO'; @@ -363,13 +363,13 @@ describe('serializer', function() { }); }); - describe('when passed value data contains a prop beginning with "$$"', function() { + describe('when passed value data contains a prop beginning with "$$"', function () { let result; - beforeEach(function() { + beforeEach(function () { result = SerializableEvent.deserialize({data: {$$foo: 'bar'}}); }); - it('should create a new prop having a function value', function() { + it('should create a new prop having a function value', function () { expect(result, 'to satisfy', { data: { foo: expect.it('to be a function') @@ -377,21 +377,21 @@ describe('serializer', function() { }); }); - it('should create a new prop returning the original value', function() { + it('should create a new prop returning the original value', function () { expect(result.data.foo(), 'to equal', 'bar'); }); - it('should remove the prop with the "$$" prefix', function() { + it('should remove the prop with the "$$" prefix', function () { expect(result, 'not to have property', '$$foo'); }); }); - describe('when the value data contains a prop with an array value', function() { - beforeEach(function() { + describe('when the value data contains a prop with an array value', function () { + beforeEach(function () { sinon.spy(SerializableEvent, '_deserializeObject'); }); - it('should deserialize each prop', function() { + it('should deserialize each prop', function () { const obj = {data: {foo: [{bar: 'baz'}]}}; SerializableEvent.deserialize(obj); expect( @@ -405,8 +405,8 @@ describe('serializer', function() { }); }); - describe('create', function() { - it('should instantiate a SerializableEvent', function() { + describe('create', function () { + it('should instantiate a SerializableEvent', function () { expect( SerializableEvent.create('some-event'), 'to be a', @@ -417,10 +417,10 @@ describe('serializer', function() { }); }); - describe('SerializableWorkerResult', function() { - describe('static method', function() { - describe('create', function() { - it('should return a new SerializableWorkerResult instance', function() { + describe('SerializableWorkerResult', function () { + describe('static method', function () { + describe('create', function () { + it('should return a new SerializableWorkerResult instance', function () { expect( SerializableWorkerResult.create(), 'to be a', @@ -429,9 +429,9 @@ describe('serializer', function() { }); }); - describe('isSerializedWorkerResult', function() { - describe('when passed an instance', function() { - it('should return `true`', function() { + describe('isSerializedWorkerResult', function () { + describe('when passed an instance', function () { + it('should return `true`', function () { expect( SerializableWorkerResult.isSerializedWorkerResult( new SerializableWorkerResult() @@ -441,8 +441,8 @@ describe('serializer', function() { }); }); - describe('when passed an object with an appropriate `__type` prop', function() { - it('should return `true`', function() { + describe('when passed an object with an appropriate `__type` prop', function () { + it('should return `true`', function () { // this is the most likely use-case, as the object is transmitted over IPC // and loses its prototype const original = new SerializableWorkerResult(); @@ -454,8 +454,8 @@ describe('serializer', function() { }); }); - describe('when passed an object without an appropriate `__type` prop', function() { - it('should return `false`', function() { + describe('when passed an object without an appropriate `__type` prop', function () { + it('should return `false`', function () { expect( SerializableWorkerResult.isSerializedWorkerResult({ mister: 'mister' @@ -466,12 +466,12 @@ describe('serializer', function() { }); }); - describe('deserialize', function() { - beforeEach(function() { + describe('deserialize', function () { + beforeEach(function () { sinon.stub(SerializableEvent, 'deserialize'); }); - it('should call SerializableEvent#deserialize on each item in its `events` prop', function() { + it('should call SerializableEvent#deserialize on each item in its `events` prop', function () { const result = Object.assign( {}, SerializableWorkerResult.create([ @@ -486,7 +486,7 @@ describe('serializer', function() { ]); }); - it('should return the deserialized value', function() { + it('should return the deserialized value', function () { const result = Object.assign( {}, SerializableWorkerResult.create([ @@ -503,16 +503,16 @@ describe('serializer', function() { }); }); - describe('instance method', function() { - describe('serialize', function() { - it('should return a read-only value', function() { + describe('instance method', function () { + describe('serialize', function () { + it('should return a read-only value', function () { expect( Object.isFrozen(SerializableWorkerResult.create().serialize()), 'to be true' ); }); - it('should call `SerializableEvent#serialize` of each of its events', function() { + it('should call `SerializableEvent#serialize` of each of its events', function () { sinon.spy(SerializableEvent.prototype, 'serialize'); const events = [ SerializableEvent.create('foo'), @@ -527,11 +527,11 @@ describe('serializer', function() { }); }); }); - describe('constructor', function() { + describe('constructor', function () { // the following two tests should be combined into one, but not sure how to express // as a single assertion - it('should add a readonly `__type` prop', function() { + it('should add a readonly `__type` prop', function () { expect( new SerializableWorkerResult(), 'to have readonly property', diff --git a/test/node-unit/stack-trace-filter.spec.js b/test/node-unit/stack-trace-filter.spec.js index cd0eccd9ea..12fc937b62 100644 --- a/test/node-unit/stack-trace-filter.spec.js +++ b/test/node-unit/stack-trace-filter.spec.js @@ -3,18 +3,18 @@ var path = require('path'); var utils = require('../../lib/utils'); -describe('stackTraceFilter()', function() { - describe('on node', function() { +describe('stackTraceFilter()', function () { + describe('on node', function () { var filter = utils.stackTraceFilter(); - describe('on POSIX OS', function() { - before(function() { + describe('on POSIX OS', function () { + before(function () { if (path.sep !== '/') { this.skip(); } }); - it('should get a stack-trace as a string and prettify it', function() { + it('should get a stack-trace as a string and prettify it', function () { var stack = [ 'AssertionError: foo bar', 'at EventEmitter. (/usr/local/dev/test.js:16:12)', @@ -47,7 +47,7 @@ describe('stackTraceFilter()', function() { expect(filter(stack.join('\n')), 'to be', stack.slice(0, 7).join('\n')); }); - it('does not ignore other bower_components and components', function() { + it('does not ignore other bower_components and components', function () { var stack = [ 'Error: failed', 'at assert (index.html:11:26)', @@ -66,7 +66,7 @@ describe('stackTraceFilter()', function() { expect(filter(stack.join('\n')), 'to be', stack.slice(0, 7).join('\n')); }); - it('should replace absolute with relative paths', function() { + it('should replace absolute with relative paths', function () { var stack = [ 'Error: ' + process.cwd() + '/bla.js has a problem', 'at foo (' + process.cwd() + '/foo/index.js:13:226)', @@ -82,7 +82,7 @@ describe('stackTraceFilter()', function() { expect(filter(stack.join('\n')), 'to be', expected.join('\n')); }); - it('should not replace absolute path which has cwd as infix', function() { + it('should not replace absolute path which has cwd as infix', function () { var stack = [ 'Error: /www' + process.cwd() + '/bla.js has a problem', 'at foo (/www' + process.cwd() + '/foo/index.js:13:226)', @@ -99,14 +99,14 @@ describe('stackTraceFilter()', function() { }); }); - describe('on Windows', function() { - before(function() { + describe('on Windows', function () { + before(function () { if (path.sep === '/') { this.skip(); } }); - it('should work on Windows', function() { + it('should work on Windows', function () { var stack = [ 'Error: failed', 'at Context. (C:\\Users\\ishida\\src\\test\\test\\mytest.js:5:9)', @@ -124,14 +124,14 @@ describe('stackTraceFilter()', function() { }); }); - describe('on browser', function() { + describe('on browser', function () { var filter; - before(function() { + before(function () { global.document = true; global.location = {href: 'localhost:3000/foo/bar/index.html'}; filter = utils.stackTraceFilter(); }); - it('does not strip out other bower_components', function() { + it('does not strip out other bower_components', function () { var stack = [ 'Error: failed', 'at assert (index.html:11:26)', @@ -147,7 +147,7 @@ describe('stackTraceFilter()', function() { expect(filter(stack.join('\n')), 'to be', stack.slice(0, 7).join('\n')); }); - after(function() { + after(function () { delete global.document; delete global.location; }); diff --git a/test/node-unit/utils.spec.js b/test/node-unit/utils.spec.js index a3eda635e7..1381244a33 100644 --- a/test/node-unit/utils.spec.js +++ b/test/node-unit/utils.spec.js @@ -2,42 +2,42 @@ const rewiremock = require('rewiremock/node'); -describe('utils', function() { +describe('utils', function () { let utils; - beforeEach(function() { + beforeEach(function () { // add deps to be mocked as needed to second parameter utils = rewiremock.proxy('../../lib/utils', {}); }); - describe('function', function() { - describe('cwd()', function() { - it('should return the current working directory', function() { + describe('function', function () { + describe('cwd()', function () { + it('should return the current working directory', function () { expect(utils.cwd(), 'to be', process.cwd()); }); }); - describe('type()', function() { - it('should return "function" if the parameter is an async function', function() { + describe('type()', function () { + it('should return "function" if the parameter is an async function', function () { expect( utils.type(async () => {}), 'to be', 'function' ); }); - it('should return "error" if the parameter is an Error', function() { + it('should return "error" if the parameter is an Error', function () { expect(utils.type(new Error('err')), 'to be', 'error'); }); }); - describe('canonicalType()', function() { - it('should return "buffer" if the parameter is a Buffer', function() { + describe('canonicalType()', function () { + it('should return "buffer" if the parameter is a Buffer', function () { expect( utils.canonicalType(Buffer.from('ff', 'hex')), 'to be', 'buffer' ); }); - it('should return "asyncfunction" if the parameter is an async function', function() { + it('should return "asyncfunction" if the parameter is an async function', function () { expect( utils.canonicalType(async () => {}), 'to be', diff --git a/test/node-unit/worker.spec.js b/test/node-unit/worker.spec.js index 48a62cd833..8a7d73dca7 100644 --- a/test/node-unit/worker.spec.js +++ b/test/node-unit/worker.spec.js @@ -7,11 +7,11 @@ const sinon = require('sinon'); const WORKER_PATH = require.resolve('../../lib/nodejs/worker.js'); -describe('worker', function() { +describe('worker', function () { let worker; let stubs; - beforeEach(function() { + beforeEach(function () { stubs = { workerpool: { isMainThread: false, @@ -21,8 +21,8 @@ describe('worker', function() { sinon.spy(process, 'removeAllListeners'); }); - describe('when run as main process', function() { - it('should throw', function() { + describe('when run as main process', function () { + it('should throw', function () { expect(() => { rewiremock.proxy(WORKER_PATH, { workerpool: { @@ -34,10 +34,10 @@ describe('worker', function() { }); }); - describe('when run as worker process', function() { + describe('when run as worker process', function () { let mocha; - beforeEach(function() { + beforeEach(function () { mocha = { addFile: sinon.stub().returnsThis(), loadFilesAsync: sinon.stub().resolves(), @@ -71,24 +71,24 @@ describe('worker', function() { }); }); - it('should register itself with workerpool', function() { + it('should register itself with workerpool', function () { expect(stubs.workerpool.worker, 'to have a call satisfying', [ {run: worker.run} ]); }); - describe('function', function() { - describe('run()', function() { - describe('when called without arguments', function() { - it('should reject', async function() { + describe('function', function () { + describe('run()', function () { + describe('when called without arguments', function () { + it('should reject', async function () { return expect(worker.run, 'to be rejected with error satisfying', { code: 'ERR_MOCHA_INVALID_ARG_TYPE' }); }); }); - describe('when passed a non-string `options` value', function() { - it('should reject', async function() { + describe('when passed a non-string `options` value', function () { + it('should reject', async function () { return expect( () => worker.run('foo.js', 42), 'to be rejected with error satisfying', @@ -99,8 +99,8 @@ describe('worker', function() { }); }); - describe('when passed an invalid string `options` value', function() { - it('should reject', async function() { + describe('when passed an invalid string `options` value', function () { + it('should reject', async function () { return expect( () => worker.run('foo.js', 'tomfoolery'), 'to be rejected with error satisfying', @@ -111,8 +111,8 @@ describe('worker', function() { }); }); - describe('when called with empty "filepath" argument', function() { - it('should reject', async function() { + describe('when called with empty "filepath" argument', function () { + it('should reject', async function () { return expect( () => worker.run(''), 'to be rejected with error satisfying', @@ -123,8 +123,8 @@ describe('worker', function() { }); }); - describe('when the file at "filepath" argument is unloadable', function() { - it('should reject', async function() { + describe('when the file at "filepath" argument is unloadable', function () { + it('should reject', async function () { mocha.loadFilesAsync.rejects(); return expect( () => worker.run('some-non-existent-file.js'), @@ -133,16 +133,16 @@ describe('worker', function() { }); }); - describe('when the file at "filepath" is loadable', function() { + describe('when the file at "filepath" is loadable', function () { let result; - beforeEach(function() { + beforeEach(function () { result = SerializableWorkerResult.create(); mocha.loadFilesAsync.resolves(); mocha.run.yields(result); }); - it('should handle "--require"', async function() { + it('should handle "--require"', async function () { await worker.run( 'some-file.js', serializeJavascript({require: 'foo'}) @@ -157,7 +157,7 @@ describe('worker', function() { ).and('was called once'); }); - it('should handle "--ui"', async function() { + it('should handle "--ui"', async function () { const argv = {foo: 'bar'}; await worker.run('some-file.js', serializeJavascript(argv)); @@ -168,31 +168,31 @@ describe('worker', function() { ).and('was called once'); }); - it('should call Mocha#run', async function() { + it('should call Mocha#run', async function () { await worker.run('some-file.js'); expect(mocha.run, 'was called once'); }); - it('should remove all uncaughtException listeners', async function() { + it('should remove all uncaughtException listeners', async function () { await worker.run('some-file.js'); expect(process.removeAllListeners, 'to have a call satisfying', [ 'uncaughtException' ]); }); - it('should remove all unhandledRejection listeners', async function() { + it('should remove all unhandledRejection listeners', async function () { await worker.run('some-file.js'); expect(process.removeAllListeners, 'to have a call satisfying', [ 'unhandledRejection' ]); }); - describe('when serialization succeeds', function() { - beforeEach(function() { + describe('when serialization succeeds', function () { + beforeEach(function () { stubs.serializer.serialize.returnsArg(0); }); - it('should resolve with a SerializedWorkerResult', async function() { + it('should resolve with a SerializedWorkerResult', async function () { return expect( worker.run('some-file.js'), 'to be fulfilled with', @@ -201,18 +201,18 @@ describe('worker', function() { }); }); - describe('when serialization fails', function() { - beforeEach(function() { + describe('when serialization fails', function () { + beforeEach(function () { stubs.serializer.serialize.throws(); }); - it('should reject', async function() { + it('should reject', async function () { return expect(worker.run('some-file.js'), 'to be rejected'); }); }); - describe('when run twice', function() { - it('should initialize only once', async function() { + describe('when run twice', function () { + it('should initialize only once', async function () { await worker.run('some-file.js'); await worker.run('some-other-file.js'); @@ -227,7 +227,7 @@ describe('worker', function() { }); }); - afterEach(function() { + afterEach(function () { sinon.restore(); // this is needed due to `require.cache` getting dumped in watch mode process.removeAllListeners('beforeExit'); diff --git a/test/only/bdd-require.spec.js b/test/only/bdd-require.spec.js index 4ae90489e4..ca6c6be4a1 100644 --- a/test/only/bdd-require.spec.js +++ b/test/only/bdd-require.spec.js @@ -6,12 +6,12 @@ var beforeEach = mocha.beforeEach; var it = mocha.it; var describe = mocha.describe; -describe('it.only via require("mocha")', function() { - beforeEach(function() { +describe('it.only via require("mocha")', function () { + beforeEach(function () { this.didRunBeforeEach = true; }); - describe('nested within a describe/context', function() { - it.only('should run all enclosing beforeEach hooks', function() { + describe('nested within a describe/context', function () { + it.only('should run all enclosing beforeEach hooks', function () { require('assert').strictEqual(this.didRunBeforeEach, true); }); }); diff --git a/test/only/global/bdd.spec.js b/test/only/global/bdd.spec.js index 39f68dfd97..dfe1c38f54 100644 --- a/test/only/global/bdd.spec.js +++ b/test/only/global/bdd.spec.js @@ -1,14 +1,14 @@ 'use strict'; // Root-only test cases -it.only('#Root-Suite, should run this bdd test-case #1', function() { +it.only('#Root-Suite, should run this bdd test-case #1', function () { expect(true, 'to be', true); }); -it('#Root-Suite, should not run this bdd test-case #2', function() { +it('#Root-Suite, should not run this bdd test-case #2', function () { expect(false, 'to be', true); }); -it('#Root-Suite, should not run this bdd test-case #3', function() { +it('#Root-Suite, should not run this bdd test-case #3', function () { expect(false, 'to be', true); }); diff --git a/test/only/global/qunit.spec.js b/test/only/global/qunit.spec.js index f60603ce8f..48e2a1ac23 100644 --- a/test/only/global/qunit.spec.js +++ b/test/only/global/qunit.spec.js @@ -1,14 +1,14 @@ 'use strict'; // Root-only test cases -test.only('#Root-Suite, should run this qunit test-case #1', function() { +test.only('#Root-Suite, should run this qunit test-case #1', function () { expect(true, 'to be', true); }); -test('#Root-Suite, should not run this qunit test-case #2', function() { +test('#Root-Suite, should not run this qunit test-case #2', function () { expect(false, 'to be', true); }); -test('#Root-Suite, should not run this qunit test-case #3', function() { +test('#Root-Suite, should not run this qunit test-case #3', function () { expect(false, 'to be', true); }); diff --git a/test/only/global/tdd.spec.js b/test/only/global/tdd.spec.js index 4c2290698b..655c022541 100644 --- a/test/only/global/tdd.spec.js +++ b/test/only/global/tdd.spec.js @@ -1,14 +1,14 @@ 'use strict'; // Root-only test cases -test.only('#Root-Suite, should run this tdd test-case #1', function() { +test.only('#Root-Suite, should run this tdd test-case #1', function () { expect(true, 'to be', true); }); -test('#Root-Suite, should not run this tdd test-case #2', function() { +test('#Root-Suite, should not run this tdd test-case #2', function () { expect(false, 'to be', true); }); -test('#Root-Suite, should not run this tdd test-case #3', function() { +test('#Root-Suite, should not run this tdd test-case #3', function () { expect(false, 'to be', true); }); diff --git a/test/reporters/base.spec.js b/test/reporters/base.spec.js index cc80964668..e13d1b2d7b 100644 --- a/test/reporters/base.spec.js +++ b/test/reporters/base.spec.js @@ -11,7 +11,7 @@ var chaiExpect = chai.expect; var createElements = helpers.createElements; var makeTest = helpers.makeTest; -describe('Base reporter', function() { +describe('Base reporter', function () { var stdout; function list(tests) { @@ -34,28 +34,28 @@ describe('Base reporter', function() { return diffStr; } - var gather = function(chunk, encoding, cb) { + var gather = function (chunk, encoding, cb) { stdout.push(chunk); }; - beforeEach(function() { + beforeEach(function () { sinon.stub(Base, 'useColors').value(false); sinon.stub(process.stdout, 'write').callsFake(gather); stdout = []; }); - afterEach(function() { + afterEach(function () { sinon.restore(); }); - describe('showDiff', function() { + describe('showDiff', function () { var err; - beforeEach(function() { + beforeEach(function () { err = new AssertionError({actual: 'foo', expected: 'bar'}); }); - it('should show diffs by default', function() { + it('should show diffs by default', function () { var test = makeTest(err); list([test]); @@ -65,7 +65,7 @@ describe('Base reporter', function() { expect(errOut, 'to match', /\+ expected/); }); - it("should show diffs if 'err.showDiff' is true", function() { + it("should show diffs if 'err.showDiff' is true", function () { err.showDiff = true; var test = makeTest(err); @@ -76,7 +76,7 @@ describe('Base reporter', function() { expect(errOut, 'to match', /\+ expected/); }); - it("should not show diffs if 'err.showDiff' is false", function() { + it("should not show diffs if 'err.showDiff' is false", function () { err.showDiff = false; var test = makeTest(err); @@ -87,7 +87,7 @@ describe('Base reporter', function() { expect(errOut, 'not to match', /\+ expected/); }); - it("should not show diffs if 'expected' is not defined", function() { + it("should not show diffs if 'expected' is not defined", function () { var _err = new Error('ouch'); var test = makeTest(_err); @@ -98,7 +98,7 @@ describe('Base reporter', function() { expect(errOut, 'not to match', /\+ expected/); }); - it("should not show diffs if 'hideDiff' is true", function() { + it("should not show diffs if 'hideDiff' is true", function () { var test = makeTest(err); sinon.stub(Base, 'hideDiff').value(true); @@ -110,9 +110,9 @@ describe('Base reporter', function() { }); }); - describe('getting two strings', function() { + describe('getting two strings', function () { // Fix regression V1.2.1(see: issue #1241) - it('should show strings diff as is', function() { + it('should show strings diff as is', function () { var err = new Error('test'); err.actual = 'foo\nbar'; err.expected = 'foo\nbaz'; @@ -130,14 +130,14 @@ describe('Base reporter', function() { }); }); - describe('diff generation', function() { + describe('diff generation', function () { var inlineDiffsStub; - beforeEach(function() { + beforeEach(function () { inlineDiffsStub = sinon.stub(Base, 'inlineDiffs'); }); - it("should generate unified diffs if 'inlineDiffs' is false", function() { + it("should generate unified diffs if 'inlineDiffs' is false", function () { var actual = 'a foo unified diff'; var expected = 'a bar unified diff'; @@ -151,7 +151,7 @@ describe('Base reporter', function() { ); }); - it("should generate inline diffs if 'inlineDiffs' is true", function() { + it("should generate inline diffs if 'inlineDiffs' is true", function () { var actual = 'a foo inline diff'; var expected = 'a bar inline diff'; @@ -165,7 +165,7 @@ describe('Base reporter', function() { ); }); - it("should truncate overly long 'actual' ", function() { + it("should truncate overly long 'actual' ", function () { var actual = ''; var i = 0; while (i++ < 120) { @@ -179,7 +179,7 @@ describe('Base reporter', function() { expect(output, 'to match', / \.\.\. Lines skipped/); }); - it("should truncate overly long 'expected' ", function() { + it("should truncate overly long 'expected' ", function () { var actual = 'a foo unified diff'; var expected = ''; var i = 0; @@ -194,12 +194,12 @@ describe('Base reporter', function() { }); }); - describe('inline strings diff', function() { - beforeEach(function() { + describe('inline strings diff', function () { + beforeEach(function () { sinon.stub(Base, 'inlineDiffs').value(true); }); - it("should show single line diff if 'inlineDiffs' is true", function() { + it("should show single line diff if 'inlineDiffs' is true", function () { var err = new Error('test'); err.actual = 'a foo inline diff'; err.expected = 'a bar inline diff'; @@ -215,7 +215,7 @@ describe('Base reporter', function() { expect(errOut, 'to match', /expected/); }); - it('should split lines if string has more than 4 line breaks', function() { + it('should split lines if string has more than 4 line breaks', function () { var err = new Error('test'); err.actual = 'a\nfoo\ninline\ndiff\nwith\nmultiple lines'; err.expected = 'a\nbar\ninline\ndiff\nwith\nmultiple lines'; @@ -237,12 +237,12 @@ describe('Base reporter', function() { }); }); - describe('unified diff', function() { - beforeEach(function() { + describe('unified diff', function () { + beforeEach(function () { sinon.stub(Base, 'inlineDiffs').value(false); }); - it('should separate diff hunks by two dashes', function() { + it('should separate diff hunks by two dashes', function () { var err = new Error('test'); err.actual = createElements({from: 2, to: 11}); err.expected = createElements({from: 1, to: 10}); @@ -272,13 +272,13 @@ describe('Base reporter', function() { /actual/ ]; - regexesToMatch.forEach(function(aRegex) { + regexesToMatch.forEach(function (aRegex) { expect(errOut, 'to match', aRegex); }); }); }); - it('should stringify objects', function() { + it('should stringify objects', function () { var err = new Error('test'); err.actual = {key: 'a1'}; err.expected = {key: 'e1'}; @@ -294,7 +294,7 @@ describe('Base reporter', function() { expect(errOut, 'to match', /\+ expected/); }); - it('should stringify Object.create(null)', function() { + it('should stringify Object.create(null)', function () { var err = new Error('test'); err.actual = Object.create(null); @@ -313,7 +313,7 @@ describe('Base reporter', function() { expect(errOut, 'to match', /\+ expected/); }); - it('should handle error messages that are not strings', function() { + it('should handle error messages that are not strings', function () { try { assert(false, true); } catch (err) { @@ -332,7 +332,7 @@ describe('Base reporter', function() { } }); - it("should interpret 'chai' module custom error messages", function() { + it("should interpret 'chai' module custom error messages", function () { var actual = 43; var expected = 42; @@ -355,7 +355,7 @@ describe('Base reporter', function() { } }); - it("should interpret 'assert' module custom error messages", function() { + it("should interpret 'assert' module custom error messages", function () { var actual = 43; var expected = 42; @@ -380,7 +380,7 @@ describe('Base reporter', function() { } }); - it('should remove message from stack', function() { + it('should remove message from stack', function () { var err = { message: 'Error', stack: 'Error\nfoo\nbar', @@ -394,11 +394,11 @@ describe('Base reporter', function() { expect(errOut, 'to be', '1) test title:\n Error\n foo\n bar'); }); - it("should use 'inspect' if 'inspect' and 'message' are set", function() { + it("should use 'inspect' if 'inspect' and 'message' are set", function () { var err = new Error('test'); err.showDiff = false; err.message = 'error message'; - err.inspect = function() { + err.inspect = function () { return 'Inspect Error'; }; @@ -411,7 +411,7 @@ describe('Base reporter', function() { expect(errOut, 'to contain', 'Inspect Error'); }); - it("should set an empty message if neither 'inspect' nor 'message' is set", function() { + it("should set an empty message if neither 'inspect' nor 'message' is set", function () { var err = { showDiff: false }; @@ -423,7 +423,7 @@ describe('Base reporter', function() { expect(errOut, 'to be', '1) test title:'); }); - it('should not modify stack if it does not contain message', function() { + it('should not modify stack if it does not contain message', function () { var err = { message: 'Error', stack: 'foo\nbar', @@ -437,7 +437,7 @@ describe('Base reporter', function() { expect(errOut, 'to be', '1) test title:\n Error\n foo\n bar'); }); - it('should list multiple Errors per test', function() { + it('should list multiple Errors per test', function () { var err = new Error('First Error'); err.multiple = [new Error('Second Error - same test')]; var test = makeTest(err); @@ -453,15 +453,15 @@ describe('Base reporter', function() { ); }); - describe('when reporter output immune to user test changes', function() { + describe('when reporter output immune to user test changes', function () { var baseConsoleLog; - beforeEach(function() { + beforeEach(function () { sinon.stub(console, 'log'); baseConsoleLog = sinon.stub(Base, 'consoleLog'); }); - it('should let you stub out console.log without effecting reporters output', function() { + it('should let you stub out console.log without effecting reporters output', function () { Base.list([]); baseConsoleLog.restore(); @@ -469,7 +469,7 @@ describe('Base reporter', function() { expect(console.log, 'was not called'); }); - afterEach(function() { + afterEach(function () { sinon.restore(); }); }); diff --git a/test/reporters/doc.spec.js b/test/reporters/doc.spec.js index ce84a5a1b3..331ac1d86d 100644 --- a/test/reporters/doc.spec.js +++ b/test/reporters/doc.spec.js @@ -13,18 +13,18 @@ var EVENT_SUITE_END = events.EVENT_SUITE_END; var EVENT_TEST_FAIL = events.EVENT_TEST_FAIL; var EVENT_TEST_PASS = events.EVENT_TEST_PASS; -describe('Doc reporter', function() { +describe('Doc reporter', function () { var runner; var options = {}; var runReporter = makeRunReporter(Doc); - afterEach(function() { + afterEach(function () { runner = null; }); - describe('event handlers', function() { - describe("on 'suite' event", function() { - describe('when suite root does not exist', function() { + describe('event handlers', function () { + describe("on 'suite' event", function () { + describe('when suite root does not exist', function () { var expectedTitle = 'expectedTitle'; var unescapedTitle = '
    ' + expectedTitle + '
    '; var suite = { @@ -32,7 +32,7 @@ describe('Doc reporter', function() { title: expectedTitle }; - it('should log html with indents and expected title', function() { + it('should log html with indents and expected title', function () { runner = createMockRunner( 'suite', EVENT_SUITE_BEGIN, @@ -49,7 +49,7 @@ describe('Doc reporter', function() { expect(stdout, 'to equal', expectedArray); }); - it('should escape title where necessary', function() { + it('should escape title where necessary', function () { var suite = { root: false, title: unescapedTitle @@ -74,12 +74,12 @@ describe('Doc reporter', function() { }); }); - describe('when suite root exists', function() { + describe('when suite root exists', function () { var suite = { root: true }; - it('should not log any html', function() { + it('should not log any html', function () { runner = createMockRunner( 'suite', EVENT_SUITE_BEGIN, @@ -93,13 +93,13 @@ describe('Doc reporter', function() { }); }); - describe("on 'suite end' event", function() { - describe('when suite root does not exist', function() { + describe("on 'suite end' event", function () { + describe('when suite root does not exist', function () { var suite = { root: false }; - it('should log expected html with indents', function() { + it('should log expected html with indents', function () { runner = createMockRunner( 'suite end', EVENT_SUITE_END, @@ -113,12 +113,12 @@ describe('Doc reporter', function() { }); }); - describe('when suite root exists', function() { + describe('when suite root exists', function () { var suite = { root: true }; - it('should not log any html', function() { + it('should not log any html', function () { runner = createMockRunner( 'suite end', EVENT_SUITE_END, @@ -132,7 +132,7 @@ describe('Doc reporter', function() { }); }); - describe("on 'pass' event", function() { + describe("on 'pass' event", function () { var expectedTitle = 'some tite'; var expectedFile = 'testFile.spec.js'; var expectedBody = 'some body'; @@ -140,12 +140,12 @@ describe('Doc reporter', function() { title: expectedTitle, file: expectedFile, body: expectedBody, - slow: function() { + slow: function () { return ''; } }; - it('should log html with indents, expected title, and body', function() { + it('should log html with indents, expected title, and body', function () { runner = createMockRunner('pass', EVENT_TEST_PASS, null, null, test); var stdout = runReporter(this, runner, options); var expectedArray = [ @@ -156,7 +156,7 @@ describe('Doc reporter', function() { expect(stdout, 'to equal', expectedArray); }); - it('should escape title and body where necessary', function() { + it('should escape title and body where necessary', function () { var unescapedTitle = '
    ' + expectedTitle + '
    '; var unescapedFile = '
    ' + expectedFile + '
    '; var unescapedBody = '
    ' + expectedBody + '
    '; @@ -181,7 +181,7 @@ describe('Doc reporter', function() { }); }); - describe("on 'fail' event", function() { + describe("on 'fail' event", function () { var expectedTitle = 'some tite'; var expectedFile = 'testFile.spec.js'; var expectedBody = 'some body'; @@ -190,12 +190,12 @@ describe('Doc reporter', function() { title: expectedTitle, file: expectedFile, body: expectedBody, - slow: function() { + slow: function () { return ''; } }; - it('should log html with indents, expected title, body, and error', function() { + it('should log html with indents, expected title, body, and error', function () { runner = createMockRunner( 'fail two args', EVENT_TEST_FAIL, @@ -216,7 +216,7 @@ describe('Doc reporter', function() { expect(stdout, 'to equal', expectedArray); }); - it('should escape title, body, and error where necessary', function() { + it('should escape title, body, and error where necessary', function () { var unescapedTitle = '
    ' + expectedTitle + '
    '; var unescapedFile = '
    ' + expectedFile + '
    '; var unescapedBody = '
    ' + expectedBody + '
    '; diff --git a/test/reporters/dot.spec.js b/test/reporters/dot.spec.js index 43d584af3c..4f37d57575 100644 --- a/test/reporters/dot.spec.js +++ b/test/reporters/dot.spec.js @@ -16,26 +16,26 @@ var EVENT_TEST_FAIL = events.EVENT_TEST_FAIL; var EVENT_TEST_PASS = events.EVENT_TEST_PASS; var EVENT_TEST_PENDING = events.EVENT_TEST_PENDING; -describe('Dot reporter', function() { +describe('Dot reporter', function () { var windowWidthStub; var runReporter = makeRunReporter(Dot); - var noop = function() {}; + var noop = function () {}; - beforeEach(function() { + beforeEach(function () { windowWidthStub = sinon.stub(Base.window, 'width').value(0); sinon.stub(Base, 'useColors').value(false); - sinon.stub(Base, 'color').callsFake(function(type, str) { + sinon.stub(Base, 'color').callsFake(function (type, str) { return type.replace(/ /g, '-') + '_' + str; }); }); - afterEach(function() { + afterEach(function () { sinon.restore(); }); - describe('event handlers', function() { - describe("on 'start' event", function() { - it('should write a newline', function() { + describe('event handlers', function () { + describe("on 'start' event", function () { + it('should write a newline', function () { var runner = createMockRunner('start', EVENT_RUN_BEGIN); var options = {}; var stdout = runReporter({epilogue: noop}, runner, options); @@ -46,13 +46,13 @@ describe('Dot reporter', function() { }); }); - describe("on 'pending' event", function() { - describe('when window width is greater than 1', function() { - beforeEach(function() { + describe("on 'pending' event", function () { + describe('when window width is greater than 1', function () { + beforeEach(function () { windowWidthStub.value(2); }); - it('should write a newline followed by a comma', function() { + it('should write a newline followed by a comma', function () { var runner = createMockRunner('pending', EVENT_TEST_PENDING); var options = {}; var stdout = runReporter({epilogue: noop}, runner, options); @@ -63,8 +63,8 @@ describe('Dot reporter', function() { }); }); - describe('when window width is less than or equal to 1', function() { - it('should write a comma', function() { + describe('when window width is less than or equal to 1', function () { + it('should write a comma', function () { var runner = createMockRunner('pending', EVENT_TEST_PENDING); var options = {}; var stdout = runReporter({epilogue: noop}, runner, options); @@ -76,21 +76,21 @@ describe('Dot reporter', function() { }); }); - describe("on 'pass' event", function() { + describe("on 'pass' event", function () { var test = { duration: 1, - slow: function() { + slow: function () { return 2; } }; - describe('when window width is greater than 1', function() { - beforeEach(function() { + describe('when window width is greater than 1', function () { + beforeEach(function () { windowWidthStub.value(2); }); - describe('when test speed is fast', function() { - it('should write a newline followed by a dot', function() { + describe('when test speed is fast', function () { + it('should write a newline followed by a dot', function () { var runner = createMockRunner( 'pass', EVENT_TEST_PASS, @@ -109,9 +109,9 @@ describe('Dot reporter', function() { }); }); - describe('when window width is less than or equal to 1', function() { - describe('when test speed is fast', function() { - it('should write a grey dot', function() { + describe('when window width is less than or equal to 1', function () { + describe('when test speed is fast', function () { + it('should write a grey dot', function () { var runner = createMockRunner( 'pass', EVENT_TEST_PASS, @@ -129,8 +129,8 @@ describe('Dot reporter', function() { }); }); - describe('when test speed is medium', function() { - it('should write a yellow dot', function() { + describe('when test speed is medium', function () { + it('should write a yellow dot', function () { test.duration = 2; var runner = createMockRunner( 'pass', @@ -149,8 +149,8 @@ describe('Dot reporter', function() { }); }); - describe('when test speed is slow', function() { - it('should write a bright yellow dot', function() { + describe('when test speed is slow', function () { + it('should write a bright yellow dot', function () { test.duration = 3; var runner = createMockRunner( 'pass', @@ -171,19 +171,19 @@ describe('Dot reporter', function() { }); }); - describe("on 'fail' event", function() { + describe("on 'fail' event", function () { var test = { test: { err: 'some error' } }; - describe('when window width is greater than 1', function() { - beforeEach(function() { + describe('when window width is greater than 1', function () { + beforeEach(function () { windowWidthStub.value(2); }); - it('should write a newline followed by an exclamation mark', function() { + it('should write a newline followed by an exclamation mark', function () { var runner = createMockRunner( 'fail', EVENT_TEST_FAIL, @@ -200,8 +200,8 @@ describe('Dot reporter', function() { }); }); - describe('when window width is less than or equal to 1', function() { - it('should write an exclamation mark', function() { + describe('when window width is less than or equal to 1', function () { + it('should write an exclamation mark', function () { var runner = createMockRunner( 'fail', EVENT_TEST_FAIL, @@ -219,8 +219,8 @@ describe('Dot reporter', function() { }); }); - describe("on 'end' event", function() { - it('should call epilogue', function() { + describe("on 'end' event", function () { + it('should call epilogue', function () { var runner = createMockRunner('end', EVENT_RUN_END); var fakeThis = { epilogue: sinon.stub() diff --git a/test/reporters/helpers.js b/test/reporters/helpers.js index f712e19e8b..6fedb0529e 100644 --- a/test/reporters/helpers.js +++ b/test/reporters/helpers.js @@ -54,7 +54,7 @@ function createRunnerFunction(runStr, ifStr1, ifStr2, ifStr3, arg1, arg2) { case 'start': case 'pending': case 'end': - return function(event, callback) { + return function (event, callback) { if (event === ifStr1) { callback(); } @@ -66,7 +66,7 @@ function createRunnerFunction(runStr, ifStr1, ifStr2, ifStr3, arg1, arg2) { case 'suite end': case 'test end': test = arg1; - return function(event, callback) { + return function (event, callback) { if (event === ifStr1) { callback(test); } @@ -74,14 +74,14 @@ function createRunnerFunction(runStr, ifStr1, ifStr2, ifStr3, arg1, arg2) { case 'fail two args': test = arg1; var expectedError = arg2; - return function(event, callback) { + return function (event, callback) { if (event === ifStr1) { callback(test, expectedError); } }; case 'start test': test = arg1; - return function(event, callback) { + return function (event, callback) { if (event === ifStr1) { callback(); } @@ -91,7 +91,7 @@ function createRunnerFunction(runStr, ifStr1, ifStr2, ifStr3, arg1, arg2) { }; case 'suite suite end': var expectedSuite = arg1; - return function(event, callback) { + return function (event, callback) { if (event === ifStr1) { callback(expectedSuite); } @@ -104,7 +104,7 @@ function createRunnerFunction(runStr, ifStr1, ifStr2, ifStr3, arg1, arg2) { }; case 'pass end': test = arg1; - return function(event, callback) { + return function (event, callback) { if (event === ifStr1) { callback(test); } @@ -115,7 +115,7 @@ function createRunnerFunction(runStr, ifStr1, ifStr2, ifStr3, arg1, arg2) { case 'test end fail': test = arg1; var error = arg2; - return function(event, callback) { + return function (event, callback) { if (event === ifStr1) { callback(); } @@ -124,7 +124,7 @@ function createRunnerFunction(runStr, ifStr1, ifStr2, ifStr3, arg1, arg2) { } }; case 'fail end pass': - return function(event, callback) { + return function (event, callback) { test = arg1; if (event === ifStr1) { callback(test, {}); @@ -146,7 +146,7 @@ function createRunnerFunction(runStr, ifStr1, ifStr2, ifStr3, arg1, arg2) { function makeTest(err) { return { err: err, - titlePath: function() { + titlePath: function () { return ['test title']; } }; @@ -170,15 +170,15 @@ function makeExpectedTest( ) { return { title: expectedTitle, - fullTitle: function() { + fullTitle: function () { return expectedFullTitle; }, file: expectedFile, duration: expectedDuration, - currentRetry: function() { + currentRetry: function () { return currentRetry; }, - slow: function() {} + slow: function () {} }; } @@ -198,12 +198,12 @@ function createRunReporterFunction(ctor) { * @param {boolean} [tee=false] - Whether to echo output to screen * @return {string[]} Lines of output written to `stdout` */ - var runReporter = function(stubSelf, runner, options, tee) { + var runReporter = function (stubSelf, runner, options, tee) { var origStdoutWrite = process.stdout.write; var stdoutWriteStub = sinon.stub(process.stdout, 'write'); var stdout = []; - var gather = function(chunk, enc, callback) { + var gather = function (chunk, enc, callback) { stdout.push(chunk); if (tee) { origStdoutWrite.call(process.stdout, chunk); diff --git a/test/reporters/json-stream.spec.js b/test/reporters/json-stream.spec.js index f4610200c1..b0b9b81407 100644 --- a/test/reporters/json-stream.spec.js +++ b/test/reporters/json-stream.spec.js @@ -14,7 +14,7 @@ var EVENT_RUN_END = events.EVENT_RUN_END; var EVENT_TEST_FAIL = events.EVENT_TEST_FAIL; var EVENT_TEST_PASS = events.EVENT_TEST_PASS; -describe('JSON Stream reporter', function() { +describe('JSON Stream reporter', function () { var runReporter = makeRunReporter(JSONStream); var expectedTitle = 'some title'; var expectedFullTitle = 'full title'; @@ -36,9 +36,9 @@ describe('JSON Stream reporter', function() { message: expectedErrorMessage }; - describe('event handlers', function() { - describe("on 'start' event", function() { - it('should write stringified start with expected total', function() { + describe('event handlers', function () { + describe("on 'start' event", function () { + it('should write stringified start with expected total', function () { var runner = createMockRunner('start', EVENT_RUN_BEGIN); var expectedTotal = 12; runner.total = expectedTotal; @@ -53,8 +53,8 @@ describe('JSON Stream reporter', function() { }); }); - describe("on 'pass' event", function() { - it('should write stringified test data', function() { + describe("on 'pass' event", function () { + it('should write stringified test data', function () { var runner = createMockRunner( 'pass', EVENT_TEST_PASS, @@ -85,9 +85,9 @@ describe('JSON Stream reporter', function() { }); }); - describe("on 'fail' event", function() { - describe('when error stack exists', function() { - it('should write stringified test data with error data', function() { + describe("on 'fail' event", function () { + describe('when error stack exists', function () { + it('should write stringified test data with error data', function () { expectedError.stack = expectedErrorStack; var runner = createMockRunner( 'fail two args', @@ -124,8 +124,8 @@ describe('JSON Stream reporter', function() { }); }); - describe('when error stack does not exist', function() { - it('should write stringified test data with error data', function() { + describe('when error stack does not exist', function () { + it('should write stringified test data with error data', function () { expectedError.stack = null; var runner = createMockRunner( 'fail two args', @@ -161,8 +161,8 @@ describe('JSON Stream reporter', function() { }); }); - describe("on 'end' event", function() { - it('should write summary statistics', function() { + describe("on 'end' event", function () { + it('should write summary statistics', function () { var runner = createMockRunner('end', EVENT_RUN_END); var options = {}; var stdout = runReporter(this, runner, options); diff --git a/test/reporters/json.spec.js b/test/reporters/json.spec.js index 8a44bc4e2a..f1f1f87922 100644 --- a/test/reporters/json.spec.js +++ b/test/reporters/json.spec.js @@ -9,15 +9,15 @@ var Suite = Mocha.Suite; var Runner = Mocha.Runner; var Test = Mocha.Test; -describe('JSON reporter', function() { +describe('JSON reporter', function () { var mocha; var suite; var runner; var testTitle = 'json test 1'; var testFile = 'someTest.spec.js'; - var noop = function() {}; + var noop = function () {}; - beforeEach(function() { + beforeEach(function () { mocha = new Mocha({ reporter: 'json' }); @@ -25,32 +25,32 @@ describe('JSON reporter', function() { runner = new Runner(suite); }); - afterEach(function() { + afterEach(function () { sinon.restore(); }); - describe('test results', function() { - beforeEach(function() { + describe('test results', function () { + beforeEach(function () { var options = {}; /* eslint no-unused-vars: off */ var mochaReporter = new mocha._reporter(runner, options); }); - beforeEach(function() { + beforeEach(function () { sinon.stub(process.stdout, 'write').callsFake(noop); }); - it('should have 1 test failure', function(done) { + it('should have 1 test failure', function (done) { var error = {message: 'oh shit'}; - var test = new Test(testTitle, function(done) { + var test = new Test(testTitle, function (done) { done(new Error(error.message)); }); test.file = testFile; suite.addTest(test); - runner.run(function(failureCount) { + runner.run(function (failureCount) { sinon.restore(); expect(runner, 'to satisfy', { testResults: { @@ -70,12 +70,12 @@ describe('JSON reporter', function() { }); }); - it('should have 1 test pending', function(done) { + it('should have 1 test pending', function (done) { var test = new Test(testTitle); test.file = testFile; suite.addTest(test); - runner.run(function(failureCount) { + runner.run(function (failureCount) { sinon.restore(); expect(runner, 'to satisfy', { testResults: { @@ -92,13 +92,13 @@ describe('JSON reporter', function() { }); }); - it('should have 1 test pass', function(done) { + it('should have 1 test pass', function (done) { const test = new Test(testTitle, () => {}); test.file = testFile; suite.addTest(test); - runner.run(function(failureCount) { + runner.run(function (failureCount) { sinon.restore(); expect(runner, 'to satisfy', { testResults: { @@ -116,7 +116,7 @@ describe('JSON reporter', function() { }); }); - it('should handle circular objects in errors', function(done) { + it('should handle circular objects in errors', function (done) { var testTitle = 'json test 1'; function CircleError() { this.message = 'oh shit'; @@ -124,14 +124,14 @@ describe('JSON reporter', function() { } var error = new CircleError(); - var test = new Test(testTitle, function(done) { + var test = new Test(testTitle, function (done) { throw error; }); test.file = testFile; suite.addTest(test); - runner.run(function(failureCount) { + runner.run(function (failureCount) { sinon.restore(); expect(runner, 'to satisfy', { testResults: { @@ -152,7 +152,7 @@ describe('JSON reporter', function() { }); }); - describe('when "reporterOption.output" is provided', function() { + describe('when "reporterOption.output" is provided', function () { var expectedDirName = 'reports'; var expectedFileName = 'reports/test-results.json'; var options = { @@ -161,29 +161,29 @@ describe('JSON reporter', function() { } }; - beforeEach(function() { + beforeEach(function () { /* eslint no-unused-vars: off */ var mochaReporter = new mocha._reporter(runner, options); }); - beforeEach(function() { + beforeEach(function () { // Add one test to suite to avoid assertions against empty test results var test = new Test(testTitle, () => {}); test.file = testFile; suite.addTest(test); }); - it('should write test results to file', function(done) { + it('should write test results to file', function (done) { const fsMkdirSync = sinon.stub(fs, 'mkdirSync'); const fsWriteFileSync = sinon.stub(fs, 'writeFileSync'); - fsWriteFileSync.callsFake(function(filename, content) { + fsWriteFileSync.callsFake(function (filename, content) { const expectedJson = JSON.stringify(runner.testResults, null, 2); expect(expectedFileName, 'to be', filename); expect(content, 'to be', expectedJson); }); - runner.run(function() { + runner.run(function () { expect( fsMkdirSync.calledWith(expectedDirName, {recursive: true}), 'to be true' @@ -193,7 +193,7 @@ describe('JSON reporter', function() { }); }); - it('should warn and write test results to console', function(done) { + it('should warn and write test results to console', function (done) { const fsMkdirSync = sinon.stub(fs, 'mkdirSync'); const fsWriteFileSync = sinon.stub(fs, 'writeFileSync'); @@ -204,7 +204,7 @@ describe('JSON reporter', function() { sinon.stub(process.stderr, 'write').callsFake(fake); sinon.stub(process.stdout, 'write').callsFake(fake); - runner.run(function() { + runner.run(function () { sinon.restore(); expect( fsMkdirSync.calledWith(expectedDirName, {recursive: true}), @@ -221,7 +221,7 @@ describe('JSON reporter', function() { }); }); - it('should throw "unsupported error" in browser', function() { + it('should throw "unsupported error" in browser', function () { sinon.stub(utils, 'isBrowser').callsFake(() => true); expect( () => new JSONReporter(runner, options), diff --git a/test/reporters/landing.spec.js b/test/reporters/landing.spec.js index a4f3b90de7..dc3351882d 100644 --- a/test/reporters/landing.spec.js +++ b/test/reporters/landing.spec.js @@ -18,7 +18,7 @@ var EVENT_TEST_END = events.EVENT_TEST_END; var STATE_FAILED = states.STATE_FAILED; var STATE_PASSED = states.STATE_PASSED; -describe('Landing reporter', function() { +describe('Landing reporter', function () { var runReporter = makeRunReporter(Landing); var resetCode = '\u001b[0m'; var expectedArray = [ @@ -32,18 +32,18 @@ describe('Landing reporter', function() { resetCode ]; - beforeEach(function() { + beforeEach(function () { sinon.stub(Base, 'useColors').value(false); sinon.stub(Base.window, 'width').value(1); }); - afterEach(function() { + afterEach(function () { sinon.restore(); }); - describe('event handlers', function() { - describe("on 'start' event", function() { - it('should write newlines', function() { + describe('event handlers', function () { + describe("on 'start' event", function () { + it('should write newlines', function () { sinon.stub(Base.cursor, 'hide'); var runner = createMockRunner('start', EVENT_RUN_BEGIN); @@ -54,7 +54,7 @@ describe('Landing reporter', function() { expect(stdout[0], 'to equal', '\n\n\n '); }); - it('should call cursor hide', function() { + it('should call cursor hide', function () { var hideCursorStub = sinon.stub(Base.cursor, 'hide'); var runner = createMockRunner('start', EVENT_RUN_BEGIN); @@ -66,9 +66,9 @@ describe('Landing reporter', function() { }); }); - describe("on 'test end' event", function() { - describe('when test passes', function() { - it('should write expected landing strip', function() { + describe("on 'test end' event", function () { + describe('when test passes', function () { + it('should write expected landing strip', function () { var test = { state: STATE_PASSED }; @@ -87,8 +87,8 @@ describe('Landing reporter', function() { }); }); - describe('when test fails', function() { - it('should write expected landing strip', function() { + describe('when test fails', function () { + it('should write expected landing strip', function () { var test = { state: STATE_FAILED }; @@ -109,8 +109,8 @@ describe('Landing reporter', function() { }); }); - describe("on 'end' event", function() { - it('should call cursor show and epilogue', function() { + describe("on 'end' event", function () { + it('should call cursor show and epilogue', function () { var showCursorStub = sinon.stub(Base.cursor, 'show'); var fakeThis = { diff --git a/test/reporters/list.spec.js b/test/reporters/list.spec.js index 1954a2c41f..b704f77c9d 100644 --- a/test/reporters/list.spec.js +++ b/test/reporters/list.spec.js @@ -17,30 +17,30 @@ var EVENT_TEST_FAIL = events.EVENT_TEST_FAIL; var EVENT_TEST_PASS = events.EVENT_TEST_PASS; var EVENT_TEST_PENDING = events.EVENT_TEST_PENDING; -describe('List reporter', function() { +describe('List reporter', function () { var runReporter = makeRunReporter(List); var expectedTitle = 'some title'; var expectedDuration = 100; - var noop = function() {}; + var noop = function () {}; var test = { - fullTitle: function() { + fullTitle: function () { return expectedTitle; }, duration: expectedDuration, slow: noop }; - beforeEach(function() { + beforeEach(function () { sinon.stub(Base, 'useColors').value(false); }); - afterEach(function() { + afterEach(function () { sinon.restore(); }); - describe('event handlers', function() { - describe("on 'start' and 'test' events", function() { - it('should write expected newline and title', function() { + describe('event handlers', function () { + describe("on 'start' and 'test' events", function () { + it('should write expected newline and title', function () { var runner = createMockRunner( 'start test', EVENT_RUN_BEGIN, @@ -62,8 +62,8 @@ describe('List reporter', function() { }); }); - describe("on 'pending' event", function() { - it('should write expected title', function() { + describe("on 'pending' event", function () { + it('should write expected title', function () { var runner = createMockRunner( 'pending test', EVENT_TEST_PENDING, @@ -82,14 +82,14 @@ describe('List reporter', function() { }); }); - describe("on 'pass' event", function() { + describe("on 'pass' event", function () { var crStub; - beforeEach(function() { + beforeEach(function () { crStub = sinon.stub(Base.cursor, 'CR').callsFake(noop); }); - it('should call cursor CR', function() { + it('should call cursor CR', function () { var runner = createMockRunner( 'pass', EVENT_TEST_PASS, @@ -107,7 +107,7 @@ describe('List reporter', function() { expect(crStub.called, 'to be true'); }); - it('should write expected symbol, title, and duration', function() { + it('should write expected symbol, title, and duration', function () { var expectedOkSymbol = 'OK'; sinon.stub(Base.symbols, 'ok').value(expectedOkSymbol); @@ -139,14 +139,14 @@ describe('List reporter', function() { }); }); - describe("on 'fail' event", function() { + describe("on 'fail' event", function () { var crStub; - beforeEach(function() { + beforeEach(function () { crStub = sinon.stub(Base.cursor, 'CR').callsFake(noop); }); - it('should call cursor CR', function() { + it('should call cursor CR', function () { var runner = createMockRunner( 'fail', EVENT_TEST_FAIL, @@ -164,7 +164,7 @@ describe('List reporter', function() { expect(crStub.called, 'to be true'); }); - it('should write expected error number and title', function() { + it('should write expected error number and title', function () { var expectedErrorCount = 1; var runner = createMockRunner( 'fail', @@ -187,7 +187,7 @@ describe('List reporter', function() { ); }); - it('should immediately construct fail strings', function() { + it('should immediately construct fail strings', function () { var actual = {a: 'actual'}; var expected = {a: 'expected'}; var checked = false; @@ -201,7 +201,7 @@ describe('List reporter', function() { null, test ); - runner.on = runner.once = function(event, callback) { + runner.on = runner.once = function (event, callback) { if ( !checked && event === 'fail' && @@ -227,8 +227,8 @@ describe('List reporter', function() { }); }); - describe("on 'end' event", function() { - it('should call epilogue', function() { + describe("on 'end' event", function () { + it('should call epilogue', function () { var runner = createMockRunner('end', EVENT_RUN_END); var options = {}; var fakeThis = { diff --git a/test/reporters/markdown.spec.js b/test/reporters/markdown.spec.js index e068c58cea..c81632a1f3 100644 --- a/test/reporters/markdown.spec.js +++ b/test/reporters/markdown.spec.js @@ -13,25 +13,25 @@ var EVENT_SUITE_BEGIN = events.EVENT_SUITE_BEGIN; var EVENT_SUITE_END = events.EVENT_SUITE_END; var EVENT_TEST_PASS = events.EVENT_TEST_PASS; -describe('Markdown reporter', function() { +describe('Markdown reporter', function () { var runReporter = makeRunReporter(Markdown); var expectedTitle = 'expected title'; var expectedFullTitle = 'full title'; var sluggedFullTitle = 'full-title'; - var noop = function() {}; + var noop = function () {}; - describe('event handlers', function() { - describe("on 'suite' event", function() { - it("should write expected slugged titles on 'end' event", function() { + describe('event handlers', function () { + describe("on 'suite' event", function () { + it("should write expected slugged titles on 'end' event", function () { var expectedSuite = { title: expectedTitle, - fullTitle: function() { + fullTitle: function () { return expectedFullTitle; }, suites: [ { title: expectedTitle, - fullTitle: function() { + fullTitle: function () { return expectedFullTitle; }, suites: [] @@ -67,11 +67,11 @@ describe('Markdown reporter', function() { }); }); - describe("on 'pass' event", function() { - it("should write test code inside js code block, on 'end' event", function() { + describe("on 'pass' event", function () { + it("should write test code inside js code block, on 'end' event", function () { var expectedSuite = { title: expectedTitle, - fullTitle: function() { + fullTitle: function () { return expectedFullTitle; }, suites: [] @@ -81,11 +81,11 @@ describe('Markdown reporter', function() { var expectedBody = 'some body'; var expectedTest = { title: expectedTitle, - fullTitle: function() { + fullTitle: function () { return expectedFullTitle; }, duration: expectedDuration, - currentRetry: function() { + currentRetry: function () { return currentRetry; }, slow: noop, diff --git a/test/reporters/min.spec.js b/test/reporters/min.spec.js index 1fe46333cf..65fc6320a3 100644 --- a/test/reporters/min.spec.js +++ b/test/reporters/min.spec.js @@ -12,13 +12,13 @@ var makeRunReporter = helpers.createRunReporterFunction; var EVENT_RUN_BEGIN = events.EVENT_RUN_BEGIN; var EVENT_RUN_END = events.EVENT_RUN_END; -describe('Min reporter', function() { +describe('Min reporter', function () { var runReporter = makeRunReporter(Min); - var noop = function() {}; + var noop = function () {}; - describe('event handlers', function() { - describe("on 'start' event", function() { - it('should clear screen then set cursor position', function() { + describe('event handlers', function () { + describe("on 'start' event", function () { + it('should clear screen then set cursor position', function () { var runner = createMockRunner('start', EVENT_RUN_BEGIN); var options = {}; var fakeThis = { @@ -31,8 +31,8 @@ describe('Min reporter', function() { }); }); - describe("on 'end' event", function() { - it('should call epilogue', function() { + describe("on 'end' event", function () { + it('should call epilogue', function () { var fakeThis = { epilogue: sinon.stub().callsFake(noop) }; diff --git a/test/reporters/nyan.spec.js b/test/reporters/nyan.spec.js index 3850ec50cb..a6e6c5def3 100644 --- a/test/reporters/nyan.spec.js +++ b/test/reporters/nyan.spec.js @@ -16,18 +16,18 @@ var EVENT_TEST_FAIL = events.EVENT_TEST_FAIL; var EVENT_TEST_PASS = events.EVENT_TEST_PASS; var EVENT_TEST_PENDING = events.EVENT_TEST_PENDING; -describe('Nyan reporter', function() { - var noop = function() {}; +describe('Nyan reporter', function () { + var noop = function () {}; - afterEach(function() { + afterEach(function () { sinon.restore(); }); - describe('event handlers', function() { + describe('event handlers', function () { var runReporter = makeRunReporter(NyanCat); - describe("on 'start' event", function() { - it('should call draw', function() { + describe("on 'start' event", function () { + it('should call draw', function () { var fakeThis = { draw: sinon.stub().callsFake(noop), generateColors: noop @@ -41,8 +41,8 @@ describe('Nyan reporter', function() { }); }); - describe("on 'pending' event", function() { - it('should call draw', function() { + describe("on 'pending' event", function () { + it('should call draw', function () { var fakeThis = { draw: sinon.stub().callsFake(noop), generateColors: noop @@ -55,8 +55,8 @@ describe('Nyan reporter', function() { }); }); - describe("on 'pass' event", function() { - it('should call draw', function() { + describe("on 'pass' event", function () { + it('should call draw', function () { var test = { duration: '', slow: noop @@ -79,8 +79,8 @@ describe('Nyan reporter', function() { }); }); - describe("on 'fail' event", function() { - it('should call draw', function() { + describe("on 'fail' event", function () { + it('should call draw', function () { var test = { err: '' }; @@ -102,8 +102,8 @@ describe('Nyan reporter', function() { }); }); - describe("on 'end' event", function() { - it('should call epilogue', function() { + describe("on 'end' event", function () { + it('should call epilogue', function () { var fakeThis = { draw: noop, epilogue: sinon.stub().callsFake(noop), @@ -116,7 +116,7 @@ describe('Nyan reporter', function() { expect(fakeThis.epilogue.called, 'to be true'); }); - it('should write numberOfLines amount of newlines', function() { + it('should write numberOfLines amount of newlines', function () { var expectedNumberOfLines = 4; var fakeThis = { draw: noop, @@ -127,7 +127,7 @@ describe('Nyan reporter', function() { var options = {}; var stdout = runReporter(fakeThis, runner, options); - var isBlankLine = function(value) { + var isBlankLine = function (value) { return value === '\n'; }; @@ -138,7 +138,7 @@ describe('Nyan reporter', function() { ); }); - it('should call Base show', function() { + it('should call Base show', function () { var showCursorStub = sinon.stub(Base.cursor, 'show'); var fakeThis = { draw: noop, @@ -155,20 +155,20 @@ describe('Nyan reporter', function() { }); }); - describe('#draw', function() { + describe('#draw', function () { var stdoutWriteStub; var stdout; - beforeEach(function() { + beforeEach(function () { stdoutWriteStub = sinon.stub(process.stdout, 'write'); - stdoutWriteStub.callsFake(function(chunk, encoding, cb) { + stdoutWriteStub.callsFake(function (chunk, encoding, cb) { stdout.push(chunk); }); stdout = []; }); - describe("when 'tick' is false", function() { - it('should draw face with expected spaces, _ and ^', function() { + describe("when 'tick' is false", function () { + it('should draw face with expected spaces, _ and ^', function () { var runner = {on: noop, once: noop}; var options = {}; var nyanCat = new NyanCat(runner, options); @@ -210,8 +210,8 @@ describe('Nyan reporter', function() { }); }); - describe("when 'tick' is true", function() { - it('should draw face with expected spaces, _ and ~', function() { + describe("when 'tick' is true", function () { + it('should draw face with expected spaces, _ and ~', function () { var runner = {on: noop, once: noop}; var options = {}; var nyanCat = new NyanCat(runner, options); @@ -254,19 +254,19 @@ describe('Nyan reporter', function() { }); }); - describe('#cursorDown', function() { + describe('#cursorDown', function () { var stdoutWriteStub; var stdout; - beforeEach(function() { + beforeEach(function () { stdoutWriteStub = sinon.stub(process.stdout, 'write'); - stdoutWriteStub.callsFake(function(chunk, encoding, cb) { + stdoutWriteStub.callsFake(function (chunk, encoding, cb) { stdout.push(chunk); }); stdout = []; }); - it('should write cursor down interaction with expected number', function() { + it('should write cursor down interaction with expected number', function () { var runner = {on: noop, once: noop}; var options = {}; var nyanCat = new NyanCat(runner, options); @@ -283,19 +283,19 @@ describe('Nyan reporter', function() { }); }); - describe('#cursorUp', function() { + describe('#cursorUp', function () { var stdoutWriteStub; var stdout; - beforeEach(function() { + beforeEach(function () { stdoutWriteStub = sinon.stub(process.stdout, 'write'); - stdoutWriteStub.callsFake(function(chunk, encoding, cb) { + stdoutWriteStub.callsFake(function (chunk, encoding, cb) { stdout.push(chunk); }); stdout = []; }); - it('should write cursor up interaction with expected number', function() { + it('should write cursor up interaction with expected number', function () { var runner = {on: noop, once: noop}; var options = {}; var nyanCat = new NyanCat(runner, options); @@ -312,23 +312,23 @@ describe('Nyan reporter', function() { }); }); - describe('#rainbowify', function() { + describe('#rainbowify', function () { var useColorsStub; - beforeEach(function() { + beforeEach(function () { useColorsStub = sinon.stub(Base, 'useColors'); }); - afterEach(function() { + afterEach(function () { sinon.restore(); }); - describe("when 'useColors' is false", function() { - beforeEach(function() { + describe("when 'useColors' is false", function () { + beforeEach(function () { useColorsStub.value(false); }); - it('should return argument string', function() { + it('should return argument string', function () { var runner = {on: noop, once: noop}; var options = {}; var nyanCat = new NyanCat(runner, options); @@ -342,12 +342,12 @@ describe('Nyan reporter', function() { }); }); - describe("when 'useColors' is true", function() { - beforeEach(function() { + describe("when 'useColors' is true", function () { + beforeEach(function () { useColorsStub.value(true); }); - it('should return rainbowified string from the given string and predefined codes', function() { + it('should return rainbowified string from the given string and predefined codes', function () { var runner = {on: noop, once: noop}; var options = {}; var nyanCat = new NyanCat(runner, options); @@ -370,9 +370,9 @@ describe('Nyan reporter', function() { }); }); - describe('#appendRainbow', function() { - describe("when 'tick' is true", function() { - it('should set an underscore segment', function() { + describe('#appendRainbow', function () { + describe("when 'tick' is true", function () { + it('should set an underscore segment', function () { var runner = {on: noop, once: noop}; var options = {}; var nyanCat = new NyanCat(runner, options); @@ -381,7 +381,7 @@ describe('Nyan reporter', function() { var trajectories = [inputArray, inputArray, inputArray, inputArray]; nyanCat.appendRainbow.call({ tick: true, - rainbowify: function(segment) { + rainbowify: function (segment) { expectedSegment = segment; }, numberOfLines: 4, @@ -392,7 +392,7 @@ describe('Nyan reporter', function() { expect(expectedSegment, 'to be', '_'); }); - it('should shift each trajectory item if its length is greater than or equal to its max width', function() { + it('should shift each trajectory item if its length is greater than or equal to its max width', function () { var runner = {on: noop, once: noop}; var options = {}; var nyanCat = new NyanCat(runner, options); @@ -409,7 +409,7 @@ describe('Nyan reporter', function() { ]; nyanCat.appendRainbow.call({ tick: true, - rainbowify: function() { + rainbowify: function () { return rainbowifyResult; }, numberOfLines: 4, @@ -421,8 +421,8 @@ describe('Nyan reporter', function() { }); }); - describe("when 'tick' is false", function() { - it('should set a dash segment', function() { + describe("when 'tick' is false", function () { + it('should set a dash segment', function () { var runner = {on: noop, once: noop}; var options = {}; var nyanCat = new NyanCat(runner, options); @@ -431,7 +431,7 @@ describe('Nyan reporter', function() { var trajectories = [inputArray, inputArray, inputArray, inputArray]; nyanCat.appendRainbow.call({ tick: false, - rainbowify: function(segment) { + rainbowify: function (segment) { expectedSegment = segment; }, numberOfLines: 4, @@ -444,21 +444,21 @@ describe('Nyan reporter', function() { }); }); - describe('#drawScoreboard', function() { + describe('#drawScoreboard', function () { var stdout; - beforeEach(function() { - sinon.stub(Base, 'color').callsFake(function(type, n) { + beforeEach(function () { + sinon.stub(Base, 'color').callsFake(function (type, n) { return type + n; }); var stdoutWriteStub = sinon.stub(process.stdout, 'write'); - stdoutWriteStub.callsFake(function(chunk, encoding, cb) { + stdoutWriteStub.callsFake(function (chunk, encoding, cb) { stdout.push(chunk); }); stdout = []; }); - it('should write scoreboard with color set with each stat', function() { + it('should write scoreboard with color set with each stat', function () { var runner = {on: noop, once: noop}; var options = {}; var nyanCat = new NyanCat(runner, options); @@ -494,7 +494,7 @@ describe('Nyan reporter', function() { expect(stdout, 'to equal', expectedArray); }); - it('should call cursorUp with given numberOfLines', function() { + it('should call cursorUp with given numberOfLines', function () { var expectedNumberOfLines = 1000; var runner = {on: noop, once: noop}; @@ -516,18 +516,18 @@ describe('Nyan reporter', function() { }); }); - describe('#drawRainbow', function() { + describe('#drawRainbow', function () { var stdout; - beforeEach(function() { + beforeEach(function () { var stdoutWriteStub = sinon.stub(process.stdout, 'write'); - stdoutWriteStub.callsFake(function(chunk, encoding, cb) { + stdoutWriteStub.callsFake(function (chunk, encoding, cb) { stdout.push(chunk); }); stdout = []; }); - it('should write width, contents and newline for each trajectory', function() { + it('should write width, contents and newline for each trajectory', function () { var expectedWidth = 444; var expectedContents = 'input'; @@ -557,7 +557,7 @@ describe('Nyan reporter', function() { expect(stdout, 'to equal', expectedArray); }); - it('should call cursorUp with given numberOfLines', function() { + it('should call cursorUp with given numberOfLines', function () { var expectedCursorArgument = null; var expectedNumberOfLines = 1000; @@ -565,7 +565,7 @@ describe('Nyan reporter', function() { var options = {}; var nyanCat = new NyanCat(runner, options); var fakeThis = { - cursorUp: function(lines) { + cursorUp: function (lines) { expectedCursorArgument = lines; }, trajectories: [['input']], @@ -583,8 +583,8 @@ describe('Nyan reporter', function() { }); }); - describe('#face', function() { - it('should expect "( x .x)" if any failures', function() { + describe('#face', function () { + it('should expect "( x .x)" if any failures', function () { var runner = {on: noop, once: noop}; var options = {}; var nyanCat = new NyanCat(runner, options); @@ -593,7 +593,7 @@ describe('Nyan reporter', function() { expect(nyanCat.face(), 'to be', '( x .x)'); }); - it('should expect "( o .o)" if any pending but none failing', function() { + it('should expect "( o .o)" if any pending but none failing', function () { var runner = {on: noop, once: noop}; var options = {}; var nyanCat = new NyanCat(runner, options); @@ -602,7 +602,7 @@ describe('Nyan reporter', function() { expect(nyanCat.face(), 'to be', '( o .o)'); }); - it('should expect "( ^ .^)" if all passing', function() { + it('should expect "( ^ .^)" if all passing', function () { var runner = {on: noop, once: noop}; var options = {}; var nyanCat = new NyanCat(runner, options); @@ -611,7 +611,7 @@ describe('Nyan reporter', function() { expect(nyanCat.face(), 'to be', '( ^ .^)'); }); - it('should expect "( - .-)" otherwise', function(done) { + it('should expect "( - .-)" otherwise', function (done) { var runner = {on: noop, once: noop}; var options = {}; var nyanCat = new NyanCat(runner, options); diff --git a/test/reporters/progress.spec.js b/test/reporters/progress.spec.js index 4f7687d874..a0c593e27f 100644 --- a/test/reporters/progress.spec.js +++ b/test/reporters/progress.spec.js @@ -14,17 +14,17 @@ var EVENT_RUN_BEGIN = events.EVENT_RUN_BEGIN; var EVENT_RUN_END = events.EVENT_RUN_END; var EVENT_TEST_END = events.EVENT_TEST_END; -describe('Progress reporter', function() { +describe('Progress reporter', function () { var runReporter = makeRunReporter(Progress); - var noop = function() {}; + var noop = function () {}; - afterEach(function() { + afterEach(function () { sinon.restore(); }); - describe('event handlers', function() { - describe("on 'start' event", function() { - it('should call cursor hide', function() { + describe('event handlers', function () { + describe("on 'start' event", function () { + it('should call cursor hide', function () { var hideCursorStub = sinon.stub(Base.cursor, 'hide'); var runner = createMockRunner('start', EVENT_RUN_BEGIN); @@ -36,9 +36,9 @@ describe('Progress reporter', function() { }); }); - describe("on 'test end' event", function() { - describe('when line has changed', function() { - it('should write expected progress of open and close options', function() { + describe("on 'test end' event", function () { + describe('when line has changed', function () { + it('should write expected progress of open and close options', function () { var crCursorStub = sinon.stub(Base.cursor, 'CR').callsFake(noop); sinon.stub(Base, 'useColors').value(false); sinon.stub(Base.window, 'width').value(5); @@ -75,8 +75,8 @@ describe('Progress reporter', function() { }); }); - describe('when line has not changed', function() { - it('should not write anything', function() { + describe('when line has not changed', function () { + it('should not write anything', function () { sinon.stub(Base, 'useColors').value(false); sinon.stub(Base.cursor, 'CR').callsFake(noop); sinon.stub(Base.window, 'width').value(-3); @@ -93,8 +93,8 @@ describe('Progress reporter', function() { }); }); - describe("on 'end' event", function() { - it('should call cursor show and epilogue', function() { + describe("on 'end' event", function () { + it('should call cursor show and epilogue', function () { var showCursorStub = sinon.stub(Base.cursor, 'show'); var fakeThis = { epilogue: sinon.spy() diff --git a/test/reporters/spec.spec.js b/test/reporters/spec.spec.js index ee482892fa..39115ffa35 100644 --- a/test/reporters/spec.spec.js +++ b/test/reporters/spec.spec.js @@ -15,22 +15,22 @@ var EVENT_TEST_FAIL = events.EVENT_TEST_FAIL; var EVENT_TEST_PASS = events.EVENT_TEST_PASS; var EVENT_TEST_PENDING = events.EVENT_TEST_PENDING; -describe('Spec reporter', function() { +describe('Spec reporter', function () { var runReporter = makeRunReporter(Spec); var expectedTitle = 'expectedTitle'; - var noop = function() {}; + var noop = function () {}; - beforeEach(function() { + beforeEach(function () { sinon.stub(Base, 'useColors').value(false); }); - afterEach(function() { + afterEach(function () { sinon.restore(); }); - describe('event handlers', function() { - describe("on 'suite' event", function() { - it('should return title', function() { + describe('event handlers', function () { + describe("on 'suite' event", function () { + it('should return title', function () { var suite = { title: expectedTitle }; @@ -50,8 +50,8 @@ describe('Spec reporter', function() { }); }); - describe("on 'pending' event", function() { - it('should return title', function() { + describe("on 'pending' event", function () { + it('should return title', function () { var suite = { title: expectedTitle }; @@ -71,14 +71,14 @@ describe('Spec reporter', function() { }); }); - describe("on 'pass' event", function() { - describe('when test speed is slow', function() { - it('should return expected tick, title, and duration', function() { + describe("on 'pass' event", function () { + describe('when test speed is slow', function () { + it('should return expected tick, title, and duration', function () { var expectedDuration = 2; var test = { title: expectedTitle, duration: expectedDuration, - slow: function() { + slow: function () { return 1; } }; @@ -106,13 +106,13 @@ describe('Spec reporter', function() { }); }); - describe('when test speed is fast', function() { - it('should return expected tick, title without a duration', function() { + describe('when test speed is fast', function () { + it('should return expected tick, title without a duration', function () { var expectedDuration = 1; var test = { title: expectedTitle, duration: expectedDuration, - slow: function() { + slow: function () { return 2; } }; @@ -134,8 +134,8 @@ describe('Spec reporter', function() { }); }); - describe("on 'fail' event", function() { - it('should return title and function count', function() { + describe("on 'fail' event", function () { + it('should return title and function count', function () { var functionCount = 1; var test = { title: expectedTitle diff --git a/test/reporters/tap.spec.js b/test/reporters/tap.spec.js index 01294e0430..9e341e846b 100644 --- a/test/reporters/tap.spec.js +++ b/test/reporters/tap.spec.js @@ -15,48 +15,48 @@ var EVENT_TEST_FAIL = events.EVENT_TEST_FAIL; var EVENT_TEST_PASS = events.EVENT_TEST_PASS; var EVENT_TEST_PENDING = events.EVENT_TEST_PENDING; -describe('TAP reporter', function() { +describe('TAP reporter', function () { var runReporter = makeRunReporter(TAP); var expectedTitle = 'some title'; var countAfterTestEnd = 2; - var noop = function() {}; + var noop = function () {}; function createTest() { return { - fullTitle: function() { + fullTitle: function () { return expectedTitle; }, slow: noop }; } - describe('TAP12 spec', function() { + describe('TAP12 spec', function () { var options = { reporterOptions: { tapVersion: '12' } }; - describe('event handlers', function() { - describe("on 'start' event", function() { + describe('event handlers', function () { + describe("on 'start' event", function () { var expectedSuite = 'some suite'; var stdout = []; - before(function() { + before(function () { var runner = createMockRunner('start', EVENT_RUN_BEGIN); runner.suite = expectedSuite; stdout = runReporter({}, runner, options); }); - it('should not write a TAP specification version', function() { + it('should not write a TAP specification version', function () { expect(stdout, 'not to contain', 'TAP version'); }); }); - describe("on 'pending' event", function() { + describe("on 'pending' event", function () { var stdout = []; - before(function() { + before(function () { var test = createTest(); var runner = createMockRunner( 'start test', @@ -69,17 +69,17 @@ describe('TAP reporter', function() { stdout = runReporter({}, runner, options); }); - it('should write expected message including count and title', function() { + it('should write expected message including count and title', function () { var expectedMessage = 'ok ' + countAfterTestEnd + ' ' + expectedTitle + ' # SKIP -\n'; expect(stdout[0], 'to equal', expectedMessage); }); }); - describe("on 'pass' event", function() { + describe("on 'pass' event", function () { var stdout; - before(function() { + before(function () { var test = createTest(); var runner = createMockRunner( 'start test', @@ -92,21 +92,21 @@ describe('TAP reporter', function() { stdout = runReporter({}, runner, options); }); - it('should write expected message including count and title', function() { + it('should write expected message including count and title', function () { var expectedMessage = 'ok ' + countAfterTestEnd + ' ' + expectedTitle + '\n'; expect(stdout[0], 'to equal', expectedMessage); }); }); - describe("on 'fail' event", function() { + describe("on 'fail' event", function () { var expectedErrorMessage = 'some error'; var expectedStack = 'some stack'; - describe("when 'error' has only message", function() { + describe("when 'error' has only message", function () { var stdout; - before(function() { + before(function () { var test = createTest(); var error = { message: expectedErrorMessage @@ -119,7 +119,7 @@ describe('TAP reporter', function() { test, error ); - runner.on = function(event, callback) { + runner.on = function (event, callback) { if (event === EVENT_TEST_END) { callback(); } else if (event === EVENT_TEST_FAIL) { @@ -130,7 +130,7 @@ describe('TAP reporter', function() { stdout = runReporter({}, runner, options); }); - it('should write expected message and error message', function() { + it('should write expected message and error message', function () { var expectedArray = [ 'not ok ' + countAfterTestEnd + ' ' + expectedTitle + '\n', ' ' + expectedErrorMessage + '\n' @@ -139,10 +139,10 @@ describe('TAP reporter', function() { }); }); - describe("when 'error' has only stack", function() { + describe("when 'error' has only stack", function () { var stdout; - before(function() { + before(function () { var test = createTest(); var error = { stack: expectedStack @@ -159,7 +159,7 @@ describe('TAP reporter', function() { stdout = runReporter({}, runner, options); }); - it('should write expected message and stack', function() { + it('should write expected message and stack', function () { var expectedArray = [ 'not ok ' + countAfterTestEnd + ' ' + expectedTitle + '\n', ' ' + expectedStack + '\n' @@ -168,10 +168,10 @@ describe('TAP reporter', function() { }); }); - describe("when 'error' has both message and stack", function() { + describe("when 'error' has both message and stack", function () { var stdout; - before(function() { + before(function () { var test = createTest(); var error = { stack: expectedStack, @@ -185,7 +185,7 @@ describe('TAP reporter', function() { test, error ); - runner.on = function(event, callback) { + runner.on = function (event, callback) { if (event === EVENT_TEST_END) { callback(); } else if (event === EVENT_TEST_FAIL) { @@ -196,7 +196,7 @@ describe('TAP reporter', function() { stdout = runReporter({}, runner, options); }); - it('should write expected message, error message, and stack', function() { + it('should write expected message, error message, and stack', function () { var expectedArray = [ 'not ok ' + countAfterTestEnd + ' ' + expectedTitle + '\n', ' ' + expectedErrorMessage + '\n', @@ -206,10 +206,10 @@ describe('TAP reporter', function() { }); }); - describe("when 'error' has neither message nor stack", function() { + describe("when 'error' has neither message nor stack", function () { var stdout; - before(function() { + before(function () { var test = createTest(); var error = {}; var runner = createMockRunner( @@ -220,7 +220,7 @@ describe('TAP reporter', function() { test, error ); - runner.on = runner.once = function(event, callback) { + runner.on = runner.once = function (event, callback) { if (event === EVENT_TEST_END) { callback(); } else if (event === EVENT_TEST_FAIL) { @@ -231,7 +231,7 @@ describe('TAP reporter', function() { stdout = runReporter({}, runner, options); }); - it('should write expected message only', function() { + it('should write expected message only', function () { var expectedArray = [ 'not ok ' + countAfterTestEnd + ' ' + expectedTitle + '\n' ]; @@ -240,10 +240,10 @@ describe('TAP reporter', function() { }); }); - describe("on 'end' event", function() { + describe("on 'end' event", function () { var stdout; - before(function() { + before(function () { var test = createTest(); var runner = createMockRunner( 'fail end pass', @@ -256,7 +256,7 @@ describe('TAP reporter', function() { stdout = runReporter({}, runner, options); }); - it('should write total tests, passes, failures, & plan', function() { + it('should write total tests, passes, failures, & plan', function () { var numberOfPasses = 1; var numberOfFails = 1; var totalTests = numberOfPasses + numberOfFails; @@ -274,35 +274,35 @@ describe('TAP reporter', function() { }); }); - describe('TAP13 spec', function() { + describe('TAP13 spec', function () { var options = { reporterOptions: { tapVersion: '13' } }; - describe('event handlers', function() { - describe("on 'start' event", function() { + describe('event handlers', function () { + describe("on 'start' event", function () { var expectedSuite = 'some suite'; var stdout; - before(function() { + before(function () { var runner = createMockRunner('start', EVENT_RUN_BEGIN); runner.suite = expectedSuite; stdout = runReporter({}, runner, options); }); - it('should write the TAP specification version', function() { + it('should write the TAP specification version', function () { var tapVersion = options.reporterOptions.tapVersion; var expectedFirstLine = 'TAP version ' + tapVersion + '\n'; expect(stdout[0], 'to equal', expectedFirstLine); }); }); - describe("on 'pending' event", function() { + describe("on 'pending' event", function () { var stdout; - before(function() { + before(function () { var test = createTest(); var runner = createMockRunner( 'start test', @@ -315,17 +315,17 @@ describe('TAP reporter', function() { stdout = runReporter({}, runner, options); }); - it('should write expected message including count and title', function() { + it('should write expected message including count and title', function () { var expectedMessage = 'ok ' + countAfterTestEnd + ' ' + expectedTitle + ' # SKIP -\n'; expect(stdout[0], 'to equal', expectedMessage); }); }); - describe("on 'pass' event", function() { + describe("on 'pass' event", function () { var stdout; - before(function() { + before(function () { var test = createTest(); var runner = createMockRunner( 'start test', @@ -338,21 +338,21 @@ describe('TAP reporter', function() { stdout = runReporter({}, runner, options); }); - it('should write expected message including count and title', function() { + it('should write expected message including count and title', function () { var expectedMessage = 'ok ' + countAfterTestEnd + ' ' + expectedTitle + '\n'; expect(stdout[0], 'to equal', expectedMessage); }); }); - describe("on 'fail' event", function() { + describe("on 'fail' event", function () { var expectedErrorMessage = 'some error'; var expectedStack = 'some stack'; - describe("when 'error' has only message", function() { + describe("when 'error' has only message", function () { var stdout; - before(function() { + before(function () { var test = createTest(); var error = { message: expectedErrorMessage @@ -365,7 +365,7 @@ describe('TAP reporter', function() { test, error ); - runner.on = function(event, callback) { + runner.on = function (event, callback) { if (event === EVENT_TEST_END) { callback(); } else if (event === EVENT_TEST_FAIL) { @@ -376,7 +376,7 @@ describe('TAP reporter', function() { stdout = runReporter({}, runner, options); }); - it('should write expected message and error message', function() { + it('should write expected message and error message', function () { var expectedArray = [ 'not ok ' + countAfterTestEnd + ' ' + expectedTitle + '\n', ' ---\n', @@ -388,10 +388,10 @@ describe('TAP reporter', function() { }); }); - describe("when 'error' has only stack", function() { + describe("when 'error' has only stack", function () { var stdout; - before(function() { + before(function () { var test = createTest(); var error = { stack: expectedStack @@ -408,7 +408,7 @@ describe('TAP reporter', function() { stdout = runReporter({}, runner, options); }); - it('should write expected message and stack', function() { + it('should write expected message and stack', function () { var expectedArray = [ 'not ok ' + countAfterTestEnd + ' ' + expectedTitle + '\n', ' ---\n', @@ -420,10 +420,10 @@ describe('TAP reporter', function() { }); }); - describe("when 'error' has both message and stack", function() { + describe("when 'error' has both message and stack", function () { var stdout; - before(function() { + before(function () { var test = createTest(); var error = { stack: expectedStack, @@ -437,7 +437,7 @@ describe('TAP reporter', function() { test, error ); - runner.on = function(event, callback) { + runner.on = function (event, callback) { if (event === EVENT_TEST_END) { callback(); } else if (event === EVENT_TEST_FAIL) { @@ -448,7 +448,7 @@ describe('TAP reporter', function() { stdout = runReporter({}, runner, options); }); - it('should write expected message, error message, and stack', function() { + it('should write expected message, error message, and stack', function () { var expectedArray = [ 'not ok ' + countAfterTestEnd + ' ' + expectedTitle + '\n', ' ---\n', @@ -462,10 +462,10 @@ describe('TAP reporter', function() { }); }); - describe("when 'error' has neither message nor stack", function() { + describe("when 'error' has neither message nor stack", function () { var stdout; - before(function() { + before(function () { var test = createTest(); var error = {}; var runner = createMockRunner( @@ -476,7 +476,7 @@ describe('TAP reporter', function() { test, error ); - runner.on = runner.once = function(event, callback) { + runner.on = runner.once = function (event, callback) { if (event === EVENT_TEST_END) { callback(); } else if (event === EVENT_TEST_FAIL) { @@ -487,7 +487,7 @@ describe('TAP reporter', function() { stdout = runReporter({}, runner, options); }); - it('should write expected message only', function() { + it('should write expected message only', function () { var expectedArray = [ 'not ok ' + countAfterTestEnd + ' ' + expectedTitle + '\n' ]; @@ -496,10 +496,10 @@ describe('TAP reporter', function() { }); }); - describe("on 'end' event", function() { + describe("on 'end' event", function () { var stdout; - before(function() { + before(function () { var test = createTest(); var runner = createMockRunner( 'fail end pass', @@ -512,7 +512,7 @@ describe('TAP reporter', function() { stdout = runReporter({}, runner, options); }); - it('should write total tests, passes, failures & plan', function() { + it('should write total tests, passes, failures & plan', function () { var numberOfPasses = 1; var numberOfFails = 1; var totalTests = numberOfPasses + numberOfFails; diff --git a/test/reporters/xunit.spec.js b/test/reporters/xunit.spec.js index 1d3bad9cb5..eaeb400da0 100644 --- a/test/reporters/xunit.spec.js +++ b/test/reporters/xunit.spec.js @@ -23,9 +23,9 @@ var EVENT_TEST_PENDING = events.EVENT_TEST_PENDING; var STATE_FAILED = states.STATE_FAILED; var STATE_PASSED = states.STATE_PASSED; -describe('XUnit reporter', function() { +describe('XUnit reporter', function () { var runner; - var noop = function() {}; + var noop = function () {}; var expectedLine = 'some-line'; var expectedClassName = 'fullTitle'; @@ -35,12 +35,12 @@ describe('XUnit reporter', function() { '\n + expected - actual\n\n -foo\n +bar\n '; var expectedStack = 'some-stack'; - beforeEach(function() { + beforeEach(function () { runner = {on: noop, once: noop}; createStatsCollector(runner); }); - describe("when 'reporterOptions.output' is provided", function() { + describe("when 'reporterOptions.output' is provided", function () { var expectedOutput = path.join(path.sep, 'path', 'to', 'some-output'); var options = { reporterOptions: { @@ -48,16 +48,16 @@ describe('XUnit reporter', function() { } }; - describe('when fileStream can be created', function() { + describe('when fileStream can be created', function () { var fsMkdirSync; var fsCreateWriteStream; - beforeEach(function() { + beforeEach(function () { fsMkdirSync = sinon.stub(fs, 'mkdirSync'); fsCreateWriteStream = sinon.stub(fs, 'createWriteStream'); }); - it('should open given file for writing, recursively creating directories in pathname', function() { + it('should open given file for writing, recursively creating directories in pathname', function () { var fakeThis = { fileStream: null }; @@ -74,13 +74,13 @@ describe('XUnit reporter', function() { expect(fsCreateWriteStream.calledWith(expectedOutput), 'to be true'); }); - afterEach(function() { + afterEach(function () { sinon.restore(); }); }); - describe('when fileStream cannot be created', function() { - describe('when given an invalid pathname', function() { + describe('when fileStream cannot be created', function () { + describe('when given an invalid pathname', function () { /** * @type {string} */ @@ -92,7 +92,7 @@ describe('XUnit reporter', function() { let cleanup; var invalidPath; - beforeEach(async function() { + beforeEach(async function () { const {dirpath, removeTempDir} = await createTempDir(); tmpdir = dirpath; cleanup = removeTempDir; @@ -106,7 +106,7 @@ describe('XUnit reporter', function() { touchFile(path.dirname(invalidPath)); }); - it('should throw system error', function() { + it('should throw system error', function () { var options = { reporterOptions: { output: invalidPath @@ -124,17 +124,17 @@ describe('XUnit reporter', function() { ); }); - afterEach(function() { + afterEach(function () { cleanup(); }); }); - describe('when run in browser', function() { - beforeEach(function() { + describe('when run in browser', function () { + beforeEach(function () { sinon.stub(fs, 'createWriteStream').value(false); }); - it('should throw unsupported error', function() { + it('should throw unsupported error', function () { var boundXUnit = XUnit.bind({}, runner, options); expect( boundXUnit, @@ -143,16 +143,16 @@ describe('XUnit reporter', function() { ); }); - afterEach(function() { + afterEach(function () { sinon.restore(); }); }); }); }); - describe('event handlers', function() { - describe("on 'pending', 'pass' and 'fail' events", function() { - it("should add test to tests called on 'end' event", function() { + describe('event handlers', function () { + describe("on 'pending', 'pass' and 'fail' events", function () { + it("should add test to tests called on 'end' event", function () { var pendingTest = { name: 'pending', slow: noop @@ -165,7 +165,7 @@ describe('XUnit reporter', function() { name: 'pass', slow: noop }; - runner.on = runner.once = function(event, callback) { + runner.on = runner.once = function (event, callback) { if (event === EVENT_TEST_PENDING) { callback(pendingTest); } else if (event === EVENT_TEST_PASS) { @@ -180,7 +180,7 @@ describe('XUnit reporter', function() { var calledTests = []; var fakeThis = { write: noop, - test: function(test) { + test: function (test) { calledTests.push(test); } }; @@ -192,7 +192,7 @@ describe('XUnit reporter', function() { }); }); - describe('#done', function() { + describe('#done', function () { var xunit; var options = { reporterOptions: {} @@ -200,36 +200,36 @@ describe('XUnit reporter', function() { var expectedNFailures = 13; var callback; - beforeEach(function() { + beforeEach(function () { callback = sinon.spy(); }); - afterEach(function() { + afterEach(function () { callback = null; xunit = null; sinon.restore(); }); - describe('when output directed to file', function() { + describe('when output directed to file', function () { var fakeThis; - beforeEach(function() { + beforeEach(function () { xunit = new XUnit(runner, options); fakeThis = { fileStream: { - end: sinon.stub().callsFake(function(chunk, encoding, cb) { + end: sinon.stub().callsFake(function (chunk, encoding, cb) { if (typeof arguments[0] === 'function') { cb = arguments[0]; } cb(); }), - write: function(chunk, encoding, cb) {} + write: function (chunk, encoding, cb) {} } }; }); - it("should run completion callback via 'fileStream.end'", function() { + it("should run completion callback via 'fileStream.end'", function () { xunit.done.call(fakeThis, expectedNFailures, callback); expect(fakeThis.fileStream.end.calledOnce, 'to be true'); @@ -238,15 +238,15 @@ describe('XUnit reporter', function() { }); }); - describe('when output directed to stdout (or console)', function() { + describe('when output directed to stdout (or console)', function () { var fakeThis; - beforeEach(function() { + beforeEach(function () { xunit = new XUnit(runner, options); fakeThis = {}; }); - it('should run completion callback', function() { + it('should run completion callback', function () { xunit.done.call(fakeThis, expectedNFailures, callback); expect(callback.calledOnce, 'to be true'); @@ -255,14 +255,14 @@ describe('XUnit reporter', function() { }); }); - describe('#write', function() { + describe('#write', function () { // :TODO: Method should be named 'writeln', not 'write' - describe('when output directed to file', function() { + describe('when output directed to file', function () { var fileStream = { write: sinon.spy() }; - it("should call 'fileStream.write' with line and newline", function() { + it("should call 'fileStream.write' with line and newline", function () { var xunit = new XUnit(runner); var fakeThis = {fileStream: fileStream}; xunit.write.call(fakeThis, expectedLine); @@ -271,8 +271,8 @@ describe('XUnit reporter', function() { }); }); - describe('when output directed to stdout', function() { - it("should call 'process.stdout.write' with line and newline", function() { + describe('when output directed to stdout', function () { + it("should call 'process.stdout.write' with line and newline", function () { var xunit = new XUnit(runner); var fakeThis = {fileStream: false}; var stdoutWriteStub = sinon.stub(process.stdout, 'write'); @@ -283,8 +283,8 @@ describe('XUnit reporter', function() { }); }); - describe('when output directed to console', function() { - it("should call 'Base.consoleLog' with line", function() { + describe('when output directed to console', function () { + it("should call 'Base.consoleLog' with line", function () { // :TODO: XUnit needs a trivially testable means to force console.log() var realProcess = process; process = false; // eslint-disable-line no-native-reassign, no-global-assign @@ -302,31 +302,31 @@ describe('XUnit reporter', function() { }); }); - describe('#test', function() { + describe('#test', function () { var expectedWrite; var fakeThis = { - write: function(str) { + write: function (str) { expectedWrite = str; } }; - beforeEach(function() { + beforeEach(function () { sinon.stub(Base, 'useColors').value(false); }); - afterEach(function() { + afterEach(function () { sinon.restore(); expectedWrite = null; }); - describe('on test failure', function() { - it('should write expected tag with error details', function() { + describe('on test failure', function () { + it('should write expected tag with error details', function () { var xunit = new XUnit(runner); var expectedTest = { state: STATE_FAILED, title: expectedTitle, parent: { - fullTitle: function() { + fullTitle: function () { return expectedClassName; } }, @@ -357,7 +357,7 @@ describe('XUnit reporter', function() { expect(expectedWrite, 'to be', expectedTag); }); - it('should handle non-string diff values', function() { + it('should handle non-string diff values', function () { var runner = new EventEmitter(); createStatsCollector(runner); var xunit = new XUnit(runner); @@ -366,7 +366,7 @@ describe('XUnit reporter', function() { state: STATE_FAILED, title: expectedTitle, parent: { - fullTitle: function() { + fullTitle: function () { return expectedClassName; } }, @@ -379,7 +379,7 @@ describe('XUnit reporter', function() { } }; - sinon.stub(xunit, 'write').callsFake(function(str) { + sinon.stub(xunit, 'write').callsFake(function (str) { expectedWrite += str; }); @@ -394,16 +394,16 @@ describe('XUnit reporter', function() { }); }); - describe('on test pending', function() { - it('should write expected tag', function() { + describe('on test pending', function () { + it('should write expected tag', function () { var xunit = new XUnit(runner); var expectedTest = { - isPending: function() { + isPending: function () { return true; }, title: expectedTitle, parent: { - fullTitle: function() { + fullTitle: function () { return expectedClassName; } }, @@ -423,16 +423,16 @@ describe('XUnit reporter', function() { }); }); - describe('on test in any other state', function() { - it('should write expected tag', function() { + describe('on test in any other state', function () { + it('should write expected tag', function () { var xunit = new XUnit(runner); var expectedTest = { - isPending: function() { + isPending: function () { return false; }, title: expectedTitle, parent: { - fullTitle: function() { + fullTitle: function () { return expectedClassName; } }, @@ -452,7 +452,7 @@ describe('XUnit reporter', function() { }); }); - it('should write expected summary statistics', function() { + it('should write expected summary statistics', function () { var numTests = 0; var numPass = 0; var numFail = 0; @@ -462,7 +462,7 @@ describe('XUnit reporter', function() { message: expectedMessage, stack: expectedStack }; - var generateTest = function(passed) { + var generateTest = function (passed) { numTests++; if (passed) { numPass++; @@ -472,14 +472,14 @@ describe('XUnit reporter', function() { return { title: [expectedTitle, numTests].join(': '), state: passed ? STATE_PASSED : STATE_FAILED, - isPending: function() { + isPending: function () { return false; }, - slow: function() { + slow: function () { return false; }, parent: { - fullTitle: function() { + fullTitle: function () { return expectedClassName; } }, @@ -491,7 +491,7 @@ describe('XUnit reporter', function() { createStatsCollector(runner); var xunit = new XUnit(runner); expectedWrite = ''; - sinon.stub(xunit, 'write').callsFake(function(str) { + sinon.stub(xunit, 'write').callsFake(function (str) { expectedWrite += str; }); @@ -523,7 +523,7 @@ describe('XUnit reporter', function() { }); }); - describe('suite name', function() { + describe('suite name', function () { // Capture the events that the reporter subscribes to var events = {}; // Capture output lines (will contain the resulting XML of XUnit reporter) @@ -531,25 +531,25 @@ describe('XUnit reporter', function() { // File stream into which the XUnit reporter will write var fileStream; - before(function() { + before(function () { fileStream = { - write: function(chunk, encoding, cb) { + write: function (chunk, encoding, cb) { lines.push(chunk); } }; }); - beforeEach(function() { + beforeEach(function () { lines = []; events = {}; - runner.on = runner.once = function(eventName, eventHandler) { + runner.on = runner.once = function (eventName, eventHandler) { // Capture the event handler events[eventName] = eventHandler; }; }); - it('should use custom name if provided via reporter options', function() { + it('should use custom name if provided via reporter options', function () { var customSuiteName = 'Mocha Is Great!'; var options = { reporterOptions: { @@ -566,7 +566,7 @@ describe('XUnit reporter', function() { expect(lines[0], 'to contain', customSuiteName); }); - it('should use default name otherwise', function() { + it('should use default name otherwise', function () { var defaultSuiteName = 'Mocha Tests'; var options = { reporterOptions: {} diff --git a/test/require/require.spec.js b/test/require/require.spec.js index b5fbca95af..c48f90f3d3 100644 --- a/test/require/require.spec.js +++ b/test/require/require.spec.js @@ -1,7 +1,7 @@ 'use strict'; -describe('require test', function() { - it('should require args in order', function() { +describe('require test', function () { + it('should require args in order', function () { var req = global.required; expect(req.indexOf('a.js'), 'to be', 0); expect(req.indexOf('b.coffee'), 'to be', 1); diff --git a/test/smoke/smoke.spec.js b/test/smoke/smoke.spec.js index 7f1365f33e..8f91f2f6fe 100644 --- a/test/smoke/smoke.spec.js +++ b/test/smoke/smoke.spec.js @@ -8,8 +8,8 @@ var assert = require('assert'); -describe('a production installation of Mocha', function() { - it('should be able to execute a test', function() { +describe('a production installation of Mocha', function () { + it('should be able to execute a test', function () { assert.ok(true); }); }); diff --git a/test/unit/context.spec.js b/test/unit/context.spec.js index d04b1ececa..783219d103 100644 --- a/test/unit/context.spec.js +++ b/test/unit/context.spec.js @@ -1,27 +1,27 @@ 'use strict'; -describe('Context', function() { - beforeEach(function() { +describe('Context', function () { + beforeEach(function () { this.calls = ['before']; }); - describe('nested', function() { - beforeEach(function() { + describe('nested', function () { + beforeEach(function () { this.calls.push('before two'); }); - it('should work', function() { + it('should work', function () { expect(this.calls, 'to equal', ['before', 'before two']); this.calls.push('test'); }); - after(function() { + after(function () { expect(this.calls, 'to equal', ['before', 'before two', 'test']); this.calls.push('after two'); }); }); - after(function() { + after(function () { expect(this.calls, 'to equal', [ 'before', 'before two', @@ -31,33 +31,33 @@ describe('Context', function() { }); }); -describe('Context Siblings', function() { - beforeEach(function() { +describe('Context Siblings', function () { + beforeEach(function () { this.calls = ['before']; }); - describe('sequestered sibling', function() { - beforeEach(function() { + describe('sequestered sibling', function () { + beforeEach(function () { this.calls.push('before two'); this.hiddenFromSibling = 'This should be hidden'; }); - it('should work', function() { + it('should work', function () { expect(this.hiddenFromSibling, 'to equal', 'This should be hidden'); }); }); - describe('sibling verifiction', function() { - beforeEach(function() { + describe('sibling verifiction', function () { + beforeEach(function () { this.calls.push('before sibling'); }); - it('should not have value set within a sibling describe', function() { + it('should not have value set within a sibling describe', function () { expect('This should be hidden', 'not to equal', this.hiddenFromSibling); this.visibleFromTestSibling = 'Visible from test sibling'; }); - it('should allow test siblings to modify shared context', function() { + it('should allow test siblings to modify shared context', function () { expect( 'Visible from test sibling', 'to equal', @@ -65,33 +65,33 @@ describe('Context Siblings', function() { ); }); - it('should have reset this.calls before describe', function() { + it('should have reset this.calls before describe', function () { expect(this.calls, 'to equal', ['before', 'before sibling']); }); }); - after(function() { + after(function () { expect(this.calls, 'to equal', ['before', 'before sibling']); }); }); -describe('methods', function() { - describe('timeout()', function() { - it('should return the timeout', function() { +describe('methods', function () { + describe('timeout()', function () { + it('should return the timeout', function () { // set this explicitly because browser and node use diff settings this.timeout(1000); expect(this.timeout(), 'to be', 1000); }); }); - describe('slow()', function() { - it('should return the slow', function() { + describe('slow()', function () { + it('should return the slow', function () { expect(this.slow(), 'to be', 75); }); }); - describe('retries', function() { - it('should return the number of retries', function() { + describe('retries', function () { + it('should return the number of retries', function () { expect(this.retries(), 'to be', -1); }); }); diff --git a/test/unit/duration.spec.js b/test/unit/duration.spec.js index 2bed92565d..45d2681bcc 100644 --- a/test/unit/duration.spec.js +++ b/test/unit/duration.spec.js @@ -1,25 +1,25 @@ 'use strict'; -describe('durations', function() { - describe('when slow', function() { - it('should highlight in red', function(done) { - setTimeout(function() { +describe('durations', function () { + describe('when slow', function () { + it('should highlight in red', function (done) { + setTimeout(function () { done(); }, 100); }); }); - describe('when reasonable', function() { - it('should highlight in yellow', function(done) { - setTimeout(function() { + describe('when reasonable', function () { + it('should highlight in yellow', function (done) { + setTimeout(function () { done(); }, 50); }); }); - describe('when fast', function() { - it('should not highlight', function(done) { - setTimeout(function() { + describe('when fast', function () { + it('should not highlight', function (done) { + setTimeout(function () { done(); }, 10); }); diff --git a/test/unit/errors.spec.js b/test/unit/errors.spec.js index d610b04acd..24e81ee9b7 100644 --- a/test/unit/errors.spec.js +++ b/test/unit/errors.spec.js @@ -4,15 +4,15 @@ var errors = require('../../lib/errors'); const sinon = require('sinon'); const {createNoFilesMatchPatternError} = require('../../lib/errors'); -describe('Errors', function() { - afterEach(function() { +describe('Errors', function () { + afterEach(function () { sinon.restore(); }); var message = 'some message'; - describe('createInvalidReporterError()', function() { - it('should include expected code in thrown reporter errors', function() { + describe('createInvalidReporterError()', function () { + it('should include expected code in thrown reporter errors', function () { expect( errors.createInvalidReporterError(message, 'badReporter'), 'to satisfy', @@ -25,8 +25,8 @@ describe('Errors', function() { }); }); - describe('createInvalidInterfaceError()', function() { - it('should include expected code in thrown interface errors', function() { + describe('createInvalidInterfaceError()', function () { + it('should include expected code in thrown interface errors', function () { expect( errors.createInvalidInterfaceError(message, 'badUi'), 'to satisfy', @@ -39,9 +39,9 @@ describe('Errors', function() { }); }); - describe('createForbiddenExclusivityError()', function() { - describe('when Mocha instance is running in a worker process', function() { - it('should output a message regarding incompatibility', function() { + describe('createForbiddenExclusivityError()', function () { + describe('when Mocha instance is running in a worker process', function () { + it('should output a message regarding incompatibility', function () { var mocha = {isWorker: true}; expect( errors.createForbiddenExclusivityError(mocha, {}), @@ -54,8 +54,8 @@ describe('Errors', function() { }); }); - describe('when Mocha instance is not running in a worker process', function() { - it('should output a message regarding --forbid-only', function() { + describe('when Mocha instance is not running in a worker process', function () { + it('should output a message regarding --forbid-only', function () { var mocha = {}; expect( errors.createForbiddenExclusivityError(mocha, {}), @@ -69,8 +69,8 @@ describe('Errors', function() { }); }); - describe('createUnparsableFileError()', function() { - it('should include expected code in thrown unparsable file errors', function() { + describe('createUnparsableFileError()', function () { + it('should include expected code in thrown unparsable file errors', function () { expect( errors.createUnparsableFileError(message, 'badFilePath'), 'to satisfy', @@ -82,10 +82,10 @@ describe('Errors', function() { }); }); - describe('deprecate()', function() { + describe('deprecate()', function () { var emitWarning; - beforeEach(function() { + beforeEach(function () { if (process.emitWarning) { emitWarning = process.emitWarning; sinon.stub(process, 'emitWarning'); @@ -95,14 +95,14 @@ describe('Errors', function() { errors.deprecate.cache = {}; }); - afterEach(function() { + afterEach(function () { // if this is not set, then we created it, so we should remove it. if (!emitWarning) { delete process.emitWarning; } }); - it('should coerce its parameter to a string', function() { + it('should coerce its parameter to a string', function () { errors.deprecate(1); expect(process.emitWarning, 'to have a call satisfying', [ '1', @@ -110,22 +110,22 @@ describe('Errors', function() { ]); }); - it('should cache the message', function() { + it('should cache the message', function () { errors.deprecate('foo'); errors.deprecate('foo'); expect(process.emitWarning, 'was called times', 1); }); - it('should ignore falsy messages', function() { + it('should ignore falsy messages', function () { errors.deprecate(''); expect(process.emitWarning, 'was not called'); }); }); - describe('warn()', function() { + describe('warn()', function () { var emitWarning; - beforeEach(function() { + beforeEach(function () { if (process.emitWarning) { emitWarning = process.emitWarning; sinon.stub(process, 'emitWarning'); @@ -134,33 +134,33 @@ describe('Errors', function() { } }); - afterEach(function() { + afterEach(function () { // if this is not set, then we created it, so we should remove it. if (!emitWarning) { delete process.emitWarning; } }); - it('should call process.emitWarning', function() { + it('should call process.emitWarning', function () { errors.warn('foo'); expect(process.emitWarning, 'was called times', 1); }); - it('should not cache messages', function() { + it('should not cache messages', function () { errors.warn('foo'); errors.warn('foo'); expect(process.emitWarning, 'was called times', 2); }); - it('should ignore falsy messages', function() { + it('should ignore falsy messages', function () { errors.warn(''); expect(process.emitWarning, 'was not called'); }); }); - describe('isMochaError()', function() { - describe('when provided an Error object having a known Mocha error code', function() { - it('should return true', function() { + describe('isMochaError()', function () { + describe('when provided an Error object having a known Mocha error code', function () { + it('should return true', function () { expect( errors.isMochaError(createNoFilesMatchPatternError('derp')), 'to be true' @@ -168,16 +168,16 @@ describe('Errors', function() { }); }); - describe('when provided an Error object with a non-Mocha error code', function() { - it('should return false', function() { + describe('when provided an Error object with a non-Mocha error code', function () { + it('should return false', function () { const err = new Error(); err.code = 'ENOTEA'; expect(errors.isMochaError(err), 'to be false'); }); }); - describe('when provided a non-error', function() { - it('should return false', function() { + describe('when provided a non-error', function () { + it('should return false', function () { expect(errors.isMochaError(), 'to be false'); }); }); diff --git a/test/unit/globals.spec.js b/test/unit/globals.spec.js index 49bebd8383..9ae8c59120 100644 --- a/test/unit/globals.spec.js +++ b/test/unit/globals.spec.js @@ -1,42 +1,42 @@ 'use strict'; -describe('global leaks', function() { - before(function() { +describe('global leaks', function () { + before(function () { // uncomment to test // foo = 'hey'; // bar = 'hey'; }); - beforeEach(function() { + beforeEach(function () { // uncomment to test // foo = 'bar' }); - it('should cause tests to fail', function() { + it('should cause tests to fail', function () { // uncomment to test // foo = 'bar'; // bar = 'baz'; // baz = 'raz'; }); - it('should pass when accepted', function() { + it('should pass when accepted', function () { global.okGlobalA = 1; global.okGlobalB = 1; global.okGlobalC = 1; }); - it('should pass with wildcard', function() { + it('should pass with wildcard', function () { global.callback123 = 'foo'; global.callback345 = 'bar'; }); - it('should pass when prefixed "mocha-"', function() { + it('should pass when prefixed "mocha-"', function () { // Opera and IE do this for HTML element IDs anyway // but to sure we can assert this in any browser, simulate it. global['mocha-example'] = {nodeType: 1}; }); - afterEach(function() { + afterEach(function () { // uncomment to test // foo = 'bar' }); diff --git a/test/unit/grep.spec.js b/test/unit/grep.spec.js index 0b65dbbeef..2f2fd87400 100644 --- a/test/unit/grep.spec.js +++ b/test/unit/grep.spec.js @@ -2,27 +2,27 @@ var Mocha = require('../../lib/mocha'); -describe('Mocha', function() { - describe('"grep" option', function() { - it('should add a RegExp to the mocha.options object', function() { +describe('Mocha', function () { + describe('"grep" option', function () { + it('should add a RegExp to the mocha.options object', function () { var mocha = new Mocha({grep: /foo.*/}); expect(mocha.options.grep, 'to equal', /foo.*/); }); - it('should convert string to a RegExp', function() { + it('should convert string to a RegExp', function () { var mocha = new Mocha({grep: 'foo.*'}); expect(mocha.options.grep, 'to equal', /foo.*/); }); }); - describe('"fgrep" option', function() { - it('should escape and convert string to a RegExp', function() { + describe('"fgrep" option', function () { + it('should escape and convert string to a RegExp', function () { var mocha = new Mocha({fgrep: 'foo.*'}); expect(mocha.options.grep, 'to equal', /foo\.\*/); }); }); - describe('.grep()', function() { + describe('.grep()', function () { // Test helper function testGrep(mocha) { return function testGrep(grep, expected) { @@ -31,19 +31,19 @@ describe('Mocha', function() { }; } - it('should add a RegExp to the mocha.options object', function() { + it('should add a RegExp to the mocha.options object', function () { var test = testGrep(new Mocha()); test(/foo/, '/foo/'); }); - it('should convert grep string to a RegExp', function() { + it('should convert grep string to a RegExp', function () { var test = testGrep(new Mocha()); test('foo', '/foo/'); test('^foo.*bar$', '/^foo.*bar$/'); test('^@.*(?=\\(\\)$)', '/^@.*(?=\\(\\)$)/'); }); - it('should covert grep regex-like string to a RegExp', function() { + it('should covert grep regex-like string to a RegExp', function () { var test = testGrep(new Mocha()); test('/foo/', '/foo/'); // Keep the flags @@ -52,14 +52,14 @@ describe('Mocha', function() { test('/^foo(.*)bar/g', '/^foo(.*)bar/g'); }); - it('should return its parent Mocha object for chainability', function() { + it('should return its parent Mocha object for chainability', function () { var mocha = new Mocha(); expect(mocha.grep(), 'to be', mocha); }); }); - describe('"invert" option', function() { - it('should add a Boolean to the mocha.options object', function() { + describe('"invert" option', function () { + it('should add a Boolean to the mocha.options object', function () { var mocha = new Mocha({invert: true}); expect(mocha.options.invert, 'to be', true); }); diff --git a/test/unit/hook-async.spec.js b/test/unit/hook-async.spec.js index fc7d2b0245..6df31c5212 100644 --- a/test/unit/hook-async.spec.js +++ b/test/unit/hook-async.spec.js @@ -1,13 +1,13 @@ 'use strict'; -describe('async', function() { +describe('async', function () { var calls = []; - before(function() { + before(function () { calls.push('root before all'); }); - after(function() { + after(function () { calls.push('root after all'); expect(calls, 'to equal', [ 'root before all', @@ -38,26 +38,26 @@ describe('async', function() { ]); }); - beforeEach(function() { + beforeEach(function () { calls.push('parent before'); }); - afterEach(function() { + afterEach(function () { calls.push('parent after'); }); - describe('hooks', function() { - before(function() { + describe('hooks', function () { + before(function () { calls.push('before all'); }); - after(function() { + after(function () { calls.push('after all'); }); - beforeEach(function(done) { + beforeEach(function (done) { var ctx = this; - process.nextTick(function() { + process.nextTick(function () { calls.push('before'); if (ctx.currentTest) { calls.push('before test ' + ctx.currentTest.title); @@ -66,7 +66,7 @@ describe('async', function() { }); }); - it('one', function(done) { + it('one', function (done) { expect(calls, 'to equal', [ 'root before all', 'before all', @@ -78,7 +78,7 @@ describe('async', function() { process.nextTick(done); }); - it('two', function() { + it('two', function () { expect(calls, 'to equal', [ 'root before all', 'before all', @@ -96,7 +96,7 @@ describe('async', function() { calls.push('two'); }); - it('three', function() { + it('three', function () { expect(calls, 'to equal', [ 'root before all', 'before all', @@ -121,9 +121,9 @@ describe('async', function() { calls.push('three'); }); - afterEach(function(done) { + afterEach(function (done) { var ctx = this; - process.nextTick(function() { + process.nextTick(function () { calls.push('after'); if (ctx.currentTest) { calls.push( diff --git a/test/unit/hook-sync-nested.spec.js b/test/unit/hook-sync-nested.spec.js index b3cef8340c..c07ca20ac5 100644 --- a/test/unit/hook-sync-nested.spec.js +++ b/test/unit/hook-sync-nested.spec.js @@ -1,17 +1,17 @@ 'use strict'; -describe('serial', function() { - describe('nested', function() { +describe('serial', function () { + describe('nested', function () { var calls = []; - beforeEach(function() { + beforeEach(function () { calls.push('parent before'); if (this.currentTest) { calls.push('parent before test ' + this.currentTest.title); } }); - afterEach(function() { + afterEach(function () { calls.push('parent after'); if (this.currentTest) { calls.push( @@ -23,12 +23,12 @@ describe('serial', function() { } }); - it('foo', function() { + it('foo', function () { expect(calls, 'to equal', ['parent before', 'parent before test foo']); calls.push('foo'); }); - it('bar', function() { + it('bar', function () { expect(calls, 'to equal', [ 'parent before', 'parent before test foo', @@ -40,15 +40,15 @@ describe('serial', function() { ]); }); - describe('hooks', function() { - beforeEach(function() { + describe('hooks', function () { + beforeEach(function () { calls.push('before'); if (this.currentTest) { calls.push('before test ' + this.currentTest.title); } }); - it('one', function() { + it('one', function () { expect(calls, 'to equal', [ 'parent before', 'parent before test foo', @@ -67,7 +67,7 @@ describe('serial', function() { calls.push('one'); }); - it('two', function() { + it('two', function () { expect(calls, 'to equal', [ 'parent before', 'parent before test foo', @@ -95,7 +95,7 @@ describe('serial', function() { calls.push('two'); }); - afterEach(function() { + afterEach(function () { calls.push('after'); if (this.currentTest) { calls.push( diff --git a/test/unit/hook-sync.spec.js b/test/unit/hook-sync.spec.js index 77e0e23e71..739590364b 100644 --- a/test/unit/hook-sync.spec.js +++ b/test/unit/hook-sync.spec.js @@ -1,30 +1,30 @@ 'use strict'; -describe('serial', function() { +describe('serial', function () { var calls = []; - beforeEach(function() { + beforeEach(function () { calls.push('parent before'); }); - afterEach(function() { + afterEach(function () { calls.push('parent after'); }); - describe('hooks', function() { - beforeEach(function() { + describe('hooks', function () { + beforeEach(function () { calls.push('before'); if (this.currentTest) { calls.push('before test ' + this.currentTest.title); } }); - it('one', function() { + it('one', function () { expect(calls, 'to equal', ['parent before', 'before', 'before test one']); calls.push('one'); }); - it('two', function() { + it('two', function () { expect(calls, 'to equal', [ 'parent before', 'before', @@ -40,7 +40,7 @@ describe('serial', function() { calls.push('two'); }); - it('three', function() { + it('three', function () { expect(calls, 'to equal', [ 'parent before', 'before', @@ -63,7 +63,7 @@ describe('serial', function() { calls.push('three'); }); - afterEach(function() { + afterEach(function () { calls.push('after'); if (this.currentTest) { calls.push( @@ -72,7 +72,7 @@ describe('serial', function() { } }); - after(function() { + after(function () { expect(calls, 'to equal', [ 'parent before', 'before', diff --git a/test/unit/hook-timeout.spec.js b/test/unit/hook-timeout.spec.js index 12d9bdc1a3..b8fe108906 100644 --- a/test/unit/hook-timeout.spec.js +++ b/test/unit/hook-timeout.spec.js @@ -1,11 +1,11 @@ 'use strict'; -describe('hook timeout', function() { - before(function(done) { +describe('hook timeout', function () { + before(function (done) { setTimeout(done, 100); }); - it('should work', function(done) { + it('should work', function (done) { done(); }); }); diff --git a/test/unit/hook.spec.js b/test/unit/hook.spec.js index 5fb51733e1..3ee6c89fec 100644 --- a/test/unit/hook.spec.js +++ b/test/unit/hook.spec.js @@ -4,38 +4,38 @@ var Mocha = require('../../lib/mocha'); var Hook = Mocha.Hook; var Runnable = Mocha.Runnable; -describe('Hook', function() { +describe('Hook', function () { var hook; - beforeEach(function() { - hook = new Hook('Some hook', function() {}); + beforeEach(function () { + hook = new Hook('Some hook', function () {}); }); - afterEach(function() { + afterEach(function () { sinon.restore(); }); - describe('error', function() { - it('should set the hook._error', function() { + describe('error', function () { + it('should set the hook._error', function () { var expectedError = new Error('Expected error'); hook.error(expectedError); expect(hook._error, 'to be', expectedError); }); - it('should get the hook._error when called without arguments', function() { + it('should get the hook._error when called without arguments', function () { var expectedError = new Error('Expected error'); hook._error = expectedError; expect(hook.error(), 'to be', expectedError); }); }); - describe('reset', function() { - it('should call Runnable.reset', function() { + describe('reset', function () { + it('should call Runnable.reset', function () { var runnableResetStub = sinon.stub(Runnable.prototype, 'reset'); hook.reset(); expect(runnableResetStub, 'was called once'); }); - it('should reset the error state', function() { + it('should reset the error state', function () { hook.error(new Error('Expected error for test')); hook.reset(); expect(hook.error(), 'to be undefined'); diff --git a/test/unit/mocha.spec.js b/test/unit/mocha.spec.js index 2275a2e58c..11cdcb20b6 100644 --- a/test/unit/mocha.spec.js +++ b/test/unit/mocha.spec.js @@ -6,7 +6,7 @@ var Mocha = require('../../lib/mocha'); var utils = require('../../lib/utils'); const errors = require('../../lib/errors'); -describe('Mocha', function() { +describe('Mocha', function () { /** * Options for `Mocha` constructor */ @@ -42,7 +42,7 @@ describe('Mocha', function() { */ var reporterInstance; - beforeEach(function() { + beforeEach(function () { reporterInstance = {}; opts = {reporter: sinon.stub().returns(reporterInstance)}; @@ -83,14 +83,14 @@ describe('Mocha', function() { sinon.stub(utils, 'noop'); }); - afterEach(function() { + afterEach(function () { sinon.restore(); }); - describe('constructor', function() { + describe('constructor', function () { var mocha; - beforeEach(function() { + beforeEach(function () { mocha = sinon.createStubInstance(Mocha); mocha.timeout.returnsThis(); mocha.retries.returnsThis(); @@ -105,20 +105,20 @@ describe('Mocha', function() { sinon.stub(Mocha.prototype, 'enableGlobalTeardown').returnsThis(); }); - it('should set _cleanReferencesAfterRun to true', function() { + it('should set _cleanReferencesAfterRun to true', function () { expect(new Mocha()._cleanReferencesAfterRun, 'to be', true); }); - describe('when `timeout` option is `undefined`', function() { - it('should not attempt to set timeout', function() { + describe('when `timeout` option is `undefined`', function () { + it('should not attempt to set timeout', function () { // eslint-disable-next-line no-new new Mocha({timeout: undefined}); expect(Mocha.prototype.timeout, 'was not called'); }); }); - describe('when `timeout` option is `false`', function() { - it('should attempt to set timeout', function() { + describe('when `timeout` option is `false`', function () { + it('should attempt to set timeout', function () { // eslint-disable-next-line no-new new Mocha({timeout: false}); expect(Mocha.prototype.timeout, 'to have a call satisfying', [0]).and( @@ -127,8 +127,8 @@ describe('Mocha', function() { }); }); - describe('when `global` option is an `Array`', function() { - it('should attempt to set globals', function() { + describe('when `global` option is an `Array`', function () { + it('should attempt to set globals', function () { // eslint-disable-next-line no-new new Mocha({global: ['singular']}); expect(Mocha.prototype.global, 'to have a call satisfying', [ @@ -137,8 +137,8 @@ describe('Mocha', function() { }); }); - describe('when `retries` option is present', function() { - it('should attempt to set retries`', function() { + describe('when `retries` option is present', function () { + it('should attempt to set retries`', function () { // eslint-disable-next-line no-new new Mocha({retries: 1}); expect(Mocha.prototype.retries, 'to have a call satisfying', [1]).and( @@ -147,16 +147,16 @@ describe('Mocha', function() { }); }); - describe('when `retries` option is not present', function() { - it('should not attempt to set retries', function() { + describe('when `retries` option is not present', function () { + it('should not attempt to set retries', function () { // eslint-disable-next-line no-new new Mocha({}); expect(Mocha.prototype.retries, 'was not called'); }); }); - describe('when `rootHooks` option is truthy', function() { - it('shouid attempt to set root hooks', function() { + describe('when `rootHooks` option is truthy', function () { + it('shouid attempt to set root hooks', function () { // eslint-disable-next-line no-new new Mocha({rootHooks: ['a root hook']}); expect(Mocha.prototype.rootHooks, 'to have a call satisfying', [ @@ -165,9 +165,9 @@ describe('Mocha', function() { }); }); - describe('when `parallel` option is true', function() { - describe('and `jobs` option > 1', function() { - it('should enable parallel mode', function() { + describe('when `parallel` option is true', function () { + describe('and `jobs` option > 1', function () { + it('should enable parallel mode', function () { // eslint-disable-next-line no-new new Mocha({parallel: true, jobs: 2}); expect(Mocha.prototype.parallelMode, 'to have a call satisfying', [ @@ -176,16 +176,16 @@ describe('Mocha', function() { }); }); - describe('and `jobs` option <= 1', function() { - it('should not enable parallel mode', function() { + describe('and `jobs` option <= 1', function () { + it('should not enable parallel mode', function () { // eslint-disable-next-line no-new new Mocha({parallel: true, jobs: 1}); expect(Mocha.prototype.parallelMode, 'was not called'); }); }); - describe('when `globalSetup` option is present', function() { - it('should configure global setup fixtures', function() { + describe('when `globalSetup` option is present', function () { + it('should configure global setup fixtures', function () { const globalSetup = [() => {}]; const mocha = new Mocha({globalSetup}); expect(mocha.globalSetup, 'to have a call satisfying', [ @@ -194,8 +194,8 @@ describe('Mocha', function() { }); }); - describe('when `globalTeardown` option is present', function() { - it('should configure global teardown fixtures', function() { + describe('when `globalTeardown` option is present', function () { + it('should configure global teardown fixtures', function () { const globalTeardown = [() => {}]; const mocha = new Mocha({globalTeardown}); expect(mocha.globalTeardown, 'to have a call satisfying', [ @@ -204,8 +204,8 @@ describe('Mocha', function() { }); }); - describe('when `enableGlobalSetup` option is present', function() { - it('should toggle global setup fixtures', function() { + describe('when `enableGlobalSetup` option is present', function () { + it('should toggle global setup fixtures', function () { const mocha = new Mocha({enableGlobalSetup: 1}); expect(mocha.enableGlobalSetup, 'to have a call satisfying', [1]).and( 'was called once' @@ -213,8 +213,8 @@ describe('Mocha', function() { }); }); - describe('when `enableGlobalTeardown` option is present', function() { - it('should configure global teardown fixtures', function() { + describe('when `enableGlobalTeardown` option is present', function () { + it('should configure global teardown fixtures', function () { const mocha = new Mocha({enableGlobalTeardown: 1}); expect(mocha.enableGlobalTeardown, 'to have a call satisfying', [ 1 @@ -224,258 +224,258 @@ describe('Mocha', function() { }); }); - describe('instance method', function() { + describe('instance method', function () { var mocha; - beforeEach(function() { + beforeEach(function () { mocha = new Mocha(opts); }); - describe('allowUncaught()', function() { - it('should set the allowUncaught option to true', function() { + describe('allowUncaught()', function () { + it('should set the allowUncaught option to true', function () { mocha.allowUncaught(); expect(mocha.options, 'to have property', 'allowUncaught', true); }); - it('should set the allowUncaught option to false', function() { + it('should set the allowUncaught option to false', function () { mocha.allowUncaught(false); expect(mocha.options, 'to have property', 'allowUncaught', false); }); - it('should be chainable', function() { + it('should be chainable', function () { expect(mocha.allowUncaught(), 'to be', mocha); }); }); - describe('asyncOnly()', function() { - it('should set the asyncOnly option to true', function() { + describe('asyncOnly()', function () { + it('should set the asyncOnly option to true', function () { mocha.asyncOnly(); expect(mocha.options, 'to have property', 'asyncOnly', true); }); - it('should set the asyncOnly option to false', function() { + it('should set the asyncOnly option to false', function () { mocha.asyncOnly(false); expect(mocha.options, 'to have property', 'asyncOnly', false); }); - it('should be chainable', function() { + it('should be chainable', function () { expect(mocha.asyncOnly(), 'to be', mocha); }); }); - describe('bail()', function() { - it('should set the "bail" flag on the root suite', function() { + describe('bail()', function () { + it('should set the "bail" flag on the root suite', function () { mocha.bail(); expect(suite.bail, 'to have a call satisfying', [true]).and( 'was called once' ); }); - it('should unset the "bail" flag on the root suite', function() { + it('should unset the "bail" flag on the root suite', function () { mocha.bail(false); expect(suite.bail, 'to have a call satisfying', [false]).and( 'was called once' ); }); - it('should be chainable', function() { + it('should be chainable', function () { expect(mocha.bail(), 'to be', mocha); }); }); - describe('checkLeaks()', function() { - it('should set the checkLeaks option to true', function() { + describe('checkLeaks()', function () { + it('should set the checkLeaks option to true', function () { mocha.checkLeaks(); expect(mocha.options, 'to have property', 'checkLeaks', true); }); }); - describe('cleanReferencesAfterRun()', function() { - it('should set the _cleanReferencesAfterRun attribute', function() { + describe('cleanReferencesAfterRun()', function () { + it('should set the _cleanReferencesAfterRun attribute', function () { mocha.cleanReferencesAfterRun(); expect(mocha._cleanReferencesAfterRun, 'to be', true); }); - it('should set the _cleanReferencesAfterRun attribute to false', function() { + it('should set the _cleanReferencesAfterRun attribute to false', function () { mocha.cleanReferencesAfterRun(false); expect(mocha._cleanReferencesAfterRun, 'to be', false); }); - it('should be chainable', function() { + it('should be chainable', function () { expect(mocha.cleanReferencesAfterRun(), 'to be', mocha); }); }); - describe('color()', function() { - it('should set the color option to true', function() { + describe('color()', function () { + it('should set the color option to true', function () { mocha.color(); expect(mocha.options, 'to have property', 'color', true); }); - it('should set the color option to false', function() { + it('should set the color option to false', function () { mocha.color(false); expect(mocha.options, 'to have property', 'color', false); }); - it('should be chainable', function() { + it('should be chainable', function () { expect(mocha.color(), 'to be', mocha); }); }); - describe('delay()', function() { - it('should set the delay option to true', function() { + describe('delay()', function () { + it('should set the delay option to true', function () { mocha.delay(); expect(mocha.options, 'to have property', 'delay', true); }); - it('should be chainable', function() { + it('should be chainable', function () { expect(mocha.delay(), 'to be', mocha); }); }); - describe('diff()', function() { - it('should set the diff option to true', function() { + describe('diff()', function () { + it('should set the diff option to true', function () { mocha.diff(); expect(mocha.options, 'to have property', 'diff', true); }); - it('should set the diff option to false', function() { + it('should set the diff option to false', function () { mocha.diff(false); expect(mocha.options, 'to have property', 'diff', false); }); }); - describe('dispose()', function() { - it('should dispose the root suite', function() { + describe('dispose()', function () { + it('should dispose the root suite', function () { mocha.dispose(); expect(suite.dispose, 'was called once'); }); - it('should dispose previous test runner', function() { + it('should dispose previous test runner', function () { mocha._previousRunner = runner; mocha.dispose(); expect(runner.dispose, 'was called once'); }); - it('should unload the files', function() { + it('should unload the files', function () { var unloadFilesStub = sinon.stub(mocha, 'unloadFiles'); mocha.dispose(); expect(unloadFilesStub, 'was called once'); }); }); - describe('dryRun()', function() { - it('should set the dryRun option to true', function() { + describe('dryRun()', function () { + it('should set the dryRun option to true', function () { mocha.dryRun(); expect(mocha.options, 'to have property', 'dryRun', true); }); - it('should set the dryRun option to false', function() { + it('should set the dryRun option to false', function () { mocha.dryRun(false); expect(mocha.options, 'to have property', 'dryRun', false); }); }); - describe('failZero()', function() { - it('should set the failZero option to true', function() { + describe('failZero()', function () { + it('should set the failZero option to true', function () { mocha.failZero(); expect(mocha.options, 'to have property', 'failZero', true); }); - it('should set the failZero option to false', function() { + it('should set the failZero option to false', function () { mocha.failZero(false); expect(mocha.options, 'to have property', 'failZero', false); }); }); - describe('forbidOnly()', function() { - it('should set the forbidOnly option to true', function() { + describe('forbidOnly()', function () { + it('should set the forbidOnly option to true', function () { mocha.forbidOnly(); expect(mocha.options, 'to have property', 'forbidOnly', true); }); - it('should set the forbidOnly option to false', function() { + it('should set the forbidOnly option to false', function () { mocha.forbidOnly(false); expect(mocha.options, 'to have property', 'forbidOnly', false); }); - it('should be chainable', function() { + it('should be chainable', function () { expect(mocha.forbidOnly(), 'to be', mocha); }); }); - describe('forbidPending()', function() { - it('should set the forbidPending option to true', function() { + describe('forbidPending()', function () { + it('should set the forbidPending option to true', function () { mocha.forbidPending(); expect(mocha.options, 'to have property', 'forbidPending', true); }); - it('should set the forbidPending option to false', function() { + it('should set the forbidPending option to false', function () { mocha.forbidPending(false); expect(mocha.options, 'to have property', 'forbidPending', false); }); - it('should be chainable', function() { + it('should be chainable', function () { expect(mocha.forbidPending(), 'to be', mocha); }); }); - describe('fullTrace()', function() { - it('should set the fullTrace option to true', function() { + describe('fullTrace()', function () { + it('should set the fullTrace option to true', function () { mocha.fullTrace(); expect(mocha.options, 'to have property', 'fullTrace', true); }); - it('should set the fullTrace option to false', function() { + it('should set the fullTrace option to false', function () { mocha.fullTrace(false); expect(mocha.options, 'to have property', 'fullTrace', false); }); - it('should be chainable', function() { + it('should be chainable', function () { expect(mocha.fullTrace(), 'to be', mocha); }); }); - describe('global()', function() { - it('should be an empty array initially', function() { + describe('global()', function () { + it('should be an empty array initially', function () { expect(mocha.options.global, 'to be empty'); }); - it('should be chainable', function() { + it('should be chainable', function () { expect(mocha.global(), 'to be', mocha); }); - describe('when argument is invalid', function() { - it('should not modify the whitelist when given empty string', function() { + describe('when argument is invalid', function () { + it('should not modify the whitelist when given empty string', function () { mocha.global(''); expect(mocha.options.global, 'to be empty'); }); - it('should not modify the whitelist when given empty array', function() { + it('should not modify the whitelist when given empty array', function () { mocha.global([]); expect(mocha.options.global, 'to be empty'); }); }); - describe('when argument is valid', function() { + describe('when argument is valid', function () { var elem = 'foo'; var elem2 = 'bar'; var elem3 = 'baz'; - it('should add string to the whitelist', function() { + it('should add string to the whitelist', function () { mocha.global(elem); expect(mocha.options.global, 'to contain', elem); expect(mocha.options.global, 'to have length', 1); }); - it('should add contents of string array to the whitelist', function() { + it('should add contents of string array to the whitelist', function () { var elems = [elem, elem2]; mocha.global(elems); expect(mocha.options.global, 'to contain', elem, elem2); expect(mocha.options.global, 'to have length', elems.length); }); - it('should not have duplicates', function() { + it('should not have duplicates', function () { var mocha = new Mocha({global: [elem, elem2]}); var elems = [elem, elem2, elem3]; mocha.global(elems); @@ -485,9 +485,9 @@ describe('Mocha', function() { }); }); - describe('growl()', function() { - describe('if capable of notifications', function() { - it('should set the growl option to true', function() { + describe('growl()', function () { + describe('if capable of notifications', function () { + it('should set the growl option to true', function () { mocha.isGrowlCapable = function forceEnable() { return true; }; @@ -496,8 +496,8 @@ describe('Mocha', function() { }); }); - describe('if not capable of notifications', function() { - it('should set the growl option to false', function() { + describe('if not capable of notifications', function () { + it('should set the growl option to false', function () { mocha.isGrowlCapable = function forceDisable() { return false; }; @@ -506,56 +506,56 @@ describe('Mocha', function() { }); }); - it('should be chainable', function() { + it('should be chainable', function () { expect(mocha.growl(), 'to be', mocha); }); }); - describe('inlineDiffs()', function() { - it('should set the inlineDiffs option to true', function() { + describe('inlineDiffs()', function () { + it('should set the inlineDiffs option to true', function () { mocha.inlineDiffs(); expect(mocha.options, 'to have property', 'inlineDiffs', true); }); - it('should set the inlineDiffs option to false', function() { + it('should set the inlineDiffs option to false', function () { mocha.inlineDiffs(false); expect(mocha.options, 'to have property', 'inlineDiffs', false); }); - it('should be chainable', function() { + it('should be chainable', function () { expect(mocha.inlineDiffs(), 'to be', mocha); }); }); - describe('invert()', function() { - it('should set the invert option to true', function() { + describe('invert()', function () { + it('should set the invert option to true', function () { mocha.invert(); expect(mocha.options, 'to have property', 'invert', true); }); - it('should be chainable', function() { + it('should be chainable', function () { expect(mocha.invert(), 'to be', mocha); }); }); - describe('noHighlighting()', function() { + describe('noHighlighting()', function () { // :NOTE: Browser-only option... - it('should set the noHighlighting option to true', function() { + it('should set the noHighlighting option to true', function () { mocha.noHighlighting(); expect(mocha.options, 'to have property', 'noHighlighting', true); }); - it('should be chainable', function() { + it('should be chainable', function () { expect(mocha.noHighlighting(), 'to be', mocha); }); }); - describe('reporter()', function() { - it('should be chainable', function() { + describe('reporter()', function () { + it('should be chainable', function () { expect(mocha.reporter(), 'to be', mocha); }); - it('should keep reporterOption on options', function() { + it('should keep reporterOption on options', function () { var mocha = new Mocha({ reporter: 'spec', reporterOption: { @@ -567,7 +567,7 @@ describe('Mocha', function() { expect(mocha.options.reporterOptions, 'to have property', 'foo', 'bar'); }); - it('should support legacy reporterOptions', function() { + it('should support legacy reporterOptions', function () { var mocha = new Mocha({ reporter: 'spec', reporterOptions: { @@ -580,37 +580,37 @@ describe('Mocha', function() { }); }); - describe('run()', function() { + describe('run()', function () { let globalFixtureContext; - beforeEach(function() { + beforeEach(function () { globalFixtureContext = {}; sinon.stub(mocha, 'runGlobalSetup').returns(globalFixtureContext); sinon.stub(mocha, 'runGlobalTeardown').returns(globalFixtureContext); }); - describe('when files have been added to the Mocha instance', function() { - beforeEach(function() { + describe('when files have been added to the Mocha instance', function () { + beforeEach(function () { sinon.stub(mocha, 'loadFiles'); mocha.addFile('some-file.js'); }); - describe('when Mocha is set to eagerly load files', function() { - it('should eagerly load files', function(done) { - mocha.run(function() { + describe('when Mocha is set to eagerly load files', function () { + it('should eagerly load files', function (done) { + mocha.run(function () { expect(mocha.loadFiles, 'was called once'); done(); }); }); }); - describe('when Mocha is set to lazily load files', function() { - beforeEach(function() { + describe('when Mocha is set to lazily load files', function () { + beforeEach(function () { mocha.lazyLoadFiles(true); }); - it('should not eagerly load files', function(done) { - mocha.run(function() { + it('should not eagerly load files', function (done) { + mocha.run(function () { expect(mocha.loadFiles, 'was not called'); done(); }); @@ -618,9 +618,9 @@ describe('Mocha', function() { }); }); - describe('Runner initialization', function() { - it('should instantiate a Runner', function(done) { - mocha.run(function() { + describe('Runner initialization', function () { + it('should instantiate a Runner', function (done) { + mocha.run(function () { expect(Runner, 'to have a call satisfying', { calledWithNew: true, args: [ @@ -635,14 +635,14 @@ describe('Mocha', function() { }); }); - describe('when "grep" option is present', function() { - beforeEach(function() { + describe('when "grep" option is present', function () { + beforeEach(function () { mocha.options.grep = /foo/; mocha.options.invert = false; }); - it('should configure "grep"', function(done) { - mocha.run(function() { + it('should configure "grep"', function (done) { + mocha.run(function () { expect(runner.grep, 'to have a call satisfying', [ mocha.options.grep, mocha.options.invert @@ -652,13 +652,13 @@ describe('Mocha', function() { }); }); - describe('when "global" option is present', function() { - beforeEach(function() { + describe('when "global" option is present', function () { + beforeEach(function () { mocha.options.global = ['foo', 'bar']; }); - it('should configure global vars', function(done) { - mocha.run(function() { + it('should configure global vars', function (done) { + mocha.run(function () { expect(runner.globals, 'to have a call satisfying', [ mocha.options.global ]).and('was called once'); @@ -668,33 +668,33 @@ describe('Mocha', function() { }); }); - describe('when "growl" option is present', function() { - beforeEach(function() { + describe('when "growl" option is present', function () { + beforeEach(function () { mocha.options.growl = true; sinon.stub(Mocha.prototype, '_growl').returnsThis(); }); - it('should initialize growl support', function(done) { - mocha.run(function() { + it('should initialize growl support', function (done) { + mocha.run(function () { expect(mocha._growl, 'to have a call satisfying', [runner]); done(); }); }); }); - describe('Base reporter initialization', function() { - beforeEach(function() { + describe('Base reporter initialization', function () { + beforeEach(function () { mocha.options.inlineDiffs = 'some value'; mocha.options.diff = false; }); - describe('when "color" options is set', function() { - beforeEach(function() { + describe('when "color" options is set', function () { + beforeEach(function () { mocha.options.color = 'truthy'; }); - it('should configure the Base reporter', function(done) { - mocha.run(function() { + it('should configure the Base reporter', function (done) { + mocha.run(function () { expect(Base, 'to satisfy', { inlineDiffs: 'some value', hideDiff: true, @@ -705,8 +705,8 @@ describe('Mocha', function() { }); }); - it('should configure the Base reporter', function(done) { - mocha.run(function() { + it('should configure the Base reporter', function (done) { + mocha.run(function () { expect(Base, 'to satisfy', { inlineDiffs: 'some value', hideDiff: true @@ -716,8 +716,8 @@ describe('Mocha', function() { }); }); - it('should instantiate a reporter', function(done) { - mocha.run(function() { + it('should instantiate a reporter', function (done) { + mocha.run(function () { expect(opts.reporter, 'to have a call satisfying', { calledWithNew: true, args: [runner, mocha.options] @@ -729,28 +729,28 @@ describe('Mocha', function() { // TODO: figure out how to stub the stats collector it('should initialize the stats collector'); - describe('when a reporter instance has a "done" method', function() { - beforeEach(function() { + describe('when a reporter instance has a "done" method', function () { + beforeEach(function () { reporterInstance.done = sinon.stub().callsArgAsync(1); }); - it('should call the reporter "done" method', function(done) { - mocha.run(function() { + it('should call the reporter "done" method', function (done) { + mocha.run(function () { expect(reporterInstance.done, 'was called once'); done(); }); }); }); - it('should execute the callback when complete', function(done) { + it('should execute the callback when complete', function (done) { mocha.run(done); }); - describe('when a run is in progress', function() { - it('should throw', function(done) { + describe('when a run is in progress', function () { + it('should throw', function (done) { mocha.run(done); // this is async! expect( - function() { + function () { mocha.run(); }, 'to throw', @@ -761,7 +761,7 @@ describe('Mocha', function() { ); }); - it('should not call `Runner#runAsync`', function(done) { + it('should not call `Runner#runAsync`', function (done) { mocha.run(done); // this is async! try { mocha.run(); @@ -773,14 +773,14 @@ describe('Mocha', function() { }); }); - describe('when the `Mocha` instance is already disposed', function() { - beforeEach(function() { + describe('when the `Mocha` instance is already disposed', function () { + beforeEach(function () { mocha.dispose(); }); - it('should throw', function() { + it('should throw', function () { expect( - function() { + function () { mocha.run(); }, 'to throw', @@ -792,7 +792,7 @@ describe('Mocha', function() { ); }); - it('should not call `Runner#runAsync`', function() { + it('should not call `Runner#runAsync`', function () { try { mocha.run(); } catch (ignored) { @@ -802,17 +802,17 @@ describe('Mocha', function() { }); }); - describe('when a run has finished and is called again', function() { - beforeEach(function(done) { - mocha.run(function() { + describe('when a run has finished and is called again', function () { + beforeEach(function (done) { + mocha.run(function () { runner.runAsync.reset(); done(); }); }); - it('should throw', function() { + it('should throw', function () { expect( - function() { + function () { mocha.run(); }, 'to throw', @@ -823,7 +823,7 @@ describe('Mocha', function() { ); }); - it('should not call `Runner#runAsync()`', function() { + it('should not call `Runner#runAsync()`', function () { try { mocha.run(); } catch (ignored) { @@ -833,38 +833,38 @@ describe('Mocha', function() { }); }); - describe('when Mocha configured for multiple runs and multiple runs are attempted', function() { - beforeEach(function() { + describe('when Mocha configured for multiple runs and multiple runs are attempted', function () { + beforeEach(function () { mocha.cleanReferencesAfterRun(false); }); - it('should not throw', function(done) { - mocha.run(function() { + it('should not throw', function (done) { + mocha.run(function () { mocha.run(done); }); }); - it('should call `Runner#runAsync` for each call', function(done) { - mocha.run(function() { - mocha.run(function() { + it('should call `Runner#runAsync` for each call', function (done) { + mocha.run(function () { + mocha.run(function () { expect(runner.runAsync, 'was called twice'); done(); }); }); }); - it('should reset the root Suite between runs', function(done) { - mocha.run(function() { - mocha.run(function() { + it('should reset the root Suite between runs', function (done) { + mocha.run(function () { + mocha.run(function () { expect(suite.reset, 'was called once'); done(); }); }); }); - it('should dispose the previous runner', function(done) { - mocha.run(function() { - mocha.run(function() { + it('should dispose the previous runner', function (done) { + mocha.run(function () { + mocha.run(function () { expect(runner.dispose, 'was called once'); done(); }); @@ -872,16 +872,16 @@ describe('Mocha', function() { }); }); - describe('when global setup fixtures enabled', function() { - beforeEach(function() { + describe('when global setup fixtures enabled', function () { + beforeEach(function () { mocha.options.enableGlobalSetup = true; }); - describe('when global setup fixtures not present', function() { - beforeEach(function() { + describe('when global setup fixtures not present', function () { + beforeEach(function () { sinon.stub(mocha, 'hasGlobalSetupFixtures').returns(false); }); - it('should not run global setup fixtures', function(done) { + it('should not run global setup fixtures', function (done) { mocha.run(() => { expect(mocha.runGlobalSetup, 'was not called'); done(); @@ -889,12 +889,12 @@ describe('Mocha', function() { }); }); - describe('when global setup fixtures are present', function() { - beforeEach(function() { + describe('when global setup fixtures are present', function () { + beforeEach(function () { sinon.stub(mocha, 'hasGlobalSetupFixtures').returns(true); }); - it('should run global setup fixtures', function(done) { + it('should run global setup fixtures', function (done) { mocha.run(() => { expect(mocha.runGlobalSetup, 'to have a call satisfying', { args: [expect.it('to be', runner)] @@ -905,16 +905,16 @@ describe('Mocha', function() { }); }); - describe('when global setup fixtures disabled', function() { - beforeEach(function() { + describe('when global setup fixtures disabled', function () { + beforeEach(function () { mocha.options.enableGlobalSetup = false; }); - describe('when global setup fixtures not present', function() { - beforeEach(function() { + describe('when global setup fixtures not present', function () { + beforeEach(function () { sinon.stub(mocha, 'hasGlobalSetupFixtures').returns(false); }); - it('should not run global setup fixtures', function(done) { + it('should not run global setup fixtures', function (done) { mocha.run(() => { expect(mocha.runGlobalSetup, 'was not called'); done(); @@ -922,12 +922,12 @@ describe('Mocha', function() { }); }); - describe('when global setup fixtures are present', function() { - beforeEach(function() { + describe('when global setup fixtures are present', function () { + beforeEach(function () { sinon.stub(mocha, 'hasGlobalSetupFixtures').returns(true); }); - it('should not run global setup fixtures', function(done) { + it('should not run global setup fixtures', function (done) { mocha.run(() => { expect(mocha.runGlobalSetup, 'was not called'); done(); @@ -936,16 +936,16 @@ describe('Mocha', function() { }); }); - describe('when global teardown fixtures enabled', function() { - beforeEach(function() { + describe('when global teardown fixtures enabled', function () { + beforeEach(function () { mocha.options.enableGlobalTeardown = true; }); - describe('when global teardown fixtures not present', function() { - beforeEach(function() { + describe('when global teardown fixtures not present', function () { + beforeEach(function () { sinon.stub(mocha, 'hasGlobalTeardownFixtures').returns(false); }); - it('should not run global teardown fixtures', function(done) { + it('should not run global teardown fixtures', function (done) { mocha.run(() => { expect(mocha.runGlobalTeardown, 'was not called'); done(); @@ -953,12 +953,12 @@ describe('Mocha', function() { }); }); - describe('when global teardown fixtures are present', function() { - beforeEach(function() { + describe('when global teardown fixtures are present', function () { + beforeEach(function () { sinon.stub(mocha, 'hasGlobalTeardownFixtures').returns(true); }); - it('should run global teardown fixtures', function(done) { + it('should run global teardown fixtures', function (done) { mocha.run(() => { expect(mocha.runGlobalTeardown, 'to have a call satisfying', { args: [expect.it('to be', runner), {context: {}}] @@ -967,13 +967,13 @@ describe('Mocha', function() { }); }); - describe('when global setup fixtures are present and enabled', function() { - beforeEach(function() { + describe('when global setup fixtures are present and enabled', function () { + beforeEach(function () { sinon.stub(mocha, 'hasGlobalSetupFixtures').returns(true); mocha.options.enableGlobalSetup = true; }); - it('should use the same context as returned by `runGlobalSetup`', function(done) { + it('should use the same context as returned by `runGlobalSetup`', function (done) { mocha.run(() => { expect(mocha.runGlobalTeardown, 'to have a call satisfying', { args: [ @@ -988,16 +988,16 @@ describe('Mocha', function() { }); }); - describe('when global teardown fixtures disabled', function() { - beforeEach(function() { + describe('when global teardown fixtures disabled', function () { + beforeEach(function () { mocha.options.enableGlobalTeardown = false; }); - describe('when global teardown fixtures not present', function() { - beforeEach(function() { + describe('when global teardown fixtures not present', function () { + beforeEach(function () { sinon.stub(mocha, 'hasGlobalTeardownFixtures').returns(false); }); - it('should not run global teardown fixtures', function(done) { + it('should not run global teardown fixtures', function (done) { mocha.run(() => { expect(mocha.runGlobalTeardown, 'was not called'); done(); @@ -1005,12 +1005,12 @@ describe('Mocha', function() { }); }); - describe('when global teardown fixtures are present', function() { - beforeEach(function() { + describe('when global teardown fixtures are present', function () { + beforeEach(function () { sinon.stub(mocha, 'hasGlobalTeardownFixtures').returns(true); }); - it('should not run global teardown fixtures', function(done) { + it('should not run global teardown fixtures', function (done) { mocha.run(() => { expect(mocha.runGlobalTeardown, 'was not called'); done(); @@ -1020,15 +1020,15 @@ describe('Mocha', function() { }); }); - describe('parallelMode()', function() { - describe('when `Mocha` is running in a browser', function() { - beforeEach(function() { + describe('parallelMode()', function () { + describe('when `Mocha` is running in a browser', function () { + beforeEach(function () { sinon.stub(utils, 'isBrowser').returns(true); }); - it('should throw', function() { + it('should throw', function () { expect( - function() { + function () { mocha.parallelMode(); }, 'to throw', @@ -1038,13 +1038,13 @@ describe('Mocha', function() { }); }); - describe('unloadFile()', function() { - describe('when run in a browser', function() { - beforeEach(function() { + describe('unloadFile()', function () { + describe('when run in a browser', function () { + beforeEach(function () { sinon.stub(utils, 'isBrowser').returns(true); }); - it('should throw', function() { + it('should throw', function () { expect(() => Mocha.unloadFile('guy-fieri.js'), 'to throw', { code: 'ERR_MOCHA_UNSUPPORTED' }); @@ -1052,8 +1052,8 @@ describe('Mocha', function() { }); }); - describe('_runGlobalFixtures()', function() { - it('should execute multiple fixtures in order', async function() { + describe('_runGlobalFixtures()', function () { + it('should execute multiple fixtures in order', async function () { const fixtures = [ sinon.stub().resolves('foo'), sinon.stub().returns('bar') @@ -1073,20 +1073,20 @@ describe('Mocha', function() { }); }); - describe('runGlobalSetup()', function() { + describe('runGlobalSetup()', function () { let context; - beforeEach(function() { + beforeEach(function () { sinon.stub(mocha, '_runGlobalFixtures').resolvesArg(1); context = {}; }); - describe('when fixture(s) are present', function() { - beforeEach(function() { + describe('when fixture(s) are present', function () { + beforeEach(function () { mocha.options.globalSetup = [sinon.spy()]; }); - it('should attempt run the fixtures', async function() { + it('should attempt run the fixtures', async function () { await mocha.runGlobalSetup(context); expect(mocha._runGlobalFixtures, 'to have a call satisfying', [ mocha.options.globalSetup, @@ -1095,28 +1095,28 @@ describe('Mocha', function() { }); }); - describe('when a fixture is not present', function() { - it('should not attempt to run fixtures', async function() { + describe('when a fixture is not present', function () { + it('should not attempt to run fixtures', async function () { await mocha.runGlobalSetup(); expect(mocha._runGlobalFixtures, 'was not called'); }); }); }); - describe('runGlobalTeardown()', function() { + describe('runGlobalTeardown()', function () { let context; - beforeEach(function() { + beforeEach(function () { sinon.stub(mocha, '_runGlobalFixtures').resolvesArg(1); context = {}; }); - describe('when fixture(s) are present', function() { - beforeEach(function() { + describe('when fixture(s) are present', function () { + beforeEach(function () { mocha.options.globalTeardown = [sinon.spy()]; }); - it('should attempt to run the fixtures', async function() { + it('should attempt to run the fixtures', async function () { await mocha.runGlobalTeardown(); expect(mocha._runGlobalFixtures, 'to have a call satisfying', [ mocha.options.globalTeardown, @@ -1125,53 +1125,53 @@ describe('Mocha', function() { }); }); - describe('when a fixture is not present', function() { - it('not attempt to run the fixtures', async function() { + describe('when a fixture is not present', function () { + it('not attempt to run the fixtures', async function () { await mocha.runGlobalTeardown(); expect(mocha._runGlobalFixtures, 'was not called'); }); }); }); - describe('hasGlobalSetupFixtures()', function() { - describe('when one or more global setup fixtures are present', function() { - it('should return `true`', function() { + describe('hasGlobalSetupFixtures()', function () { + describe('when one or more global setup fixtures are present', function () { + it('should return `true`', function () { mocha.options.globalSetup = [() => {}]; expect(mocha.hasGlobalSetupFixtures(), 'to be true'); }); }); - describe('when no global setup fixtures are present', function() { - it('should return `false`', function() { + describe('when no global setup fixtures are present', function () { + it('should return `false`', function () { mocha.options.globalSetup = []; expect(mocha.hasGlobalSetupFixtures(), 'to be false'); }); }); }); - describe('hasGlobalTeardownFixtures()', function() { - describe('when one or more global teardown fixtures are present', function() { - it('should return `true`', function() { + describe('hasGlobalTeardownFixtures()', function () { + describe('when one or more global teardown fixtures are present', function () { + it('should return `true`', function () { mocha.options.globalTeardown = [() => {}]; expect(mocha.hasGlobalTeardownFixtures(), 'to be true'); }); }); - describe('when no global teardown fixtures are present', function() { - it('should return `false`', function() { + describe('when no global teardown fixtures are present', function () { + it('should return `false`', function () { mocha.options.globalTeardown = []; expect(mocha.hasGlobalTeardownFixtures(), 'to be false'); }); }); }); - describe('rootHooks()', function() { - it('should be chainable', function() { + describe('rootHooks()', function () { + it('should be chainable', function () { expect(mocha.rootHooks(), 'to be', mocha); }); - describe('when provided a single "before all" hook', function() { - it('should attach it to the root suite', function() { + describe('when provided a single "before all" hook', function () { + it('should attach it to the root suite', function () { const beforeAll = () => {}; mocha.rootHooks({beforeAll}); expect(mocha.suite.beforeAll, 'to have a call satisfying', [ @@ -1180,8 +1180,8 @@ describe('Mocha', function() { }); }); - describe('when provided a single "before each" hook', function() { - it('should attach it to the root suite', function() { + describe('when provided a single "before each" hook', function () { + it('should attach it to the root suite', function () { const beforeEach = () => {}; mocha.rootHooks({beforeEach}); expect(mocha.suite.beforeEach, 'to have a call satisfying', [ @@ -1190,8 +1190,8 @@ describe('Mocha', function() { }); }); - describe('when provided a single "after all" hook', function() { - it('should attach it to the root suite', function() { + describe('when provided a single "after all" hook', function () { + it('should attach it to the root suite', function () { const afterAll = () => {}; mocha.rootHooks({afterAll}); expect(mocha.suite.afterAll, 'to have a call satisfying', [ @@ -1200,8 +1200,8 @@ describe('Mocha', function() { }); }); - describe('when provided a single "after each" hook', function() { - it('should attach it to the root suite', function() { + describe('when provided a single "after each" hook', function () { + it('should attach it to the root suite', function () { const afterEach = () => {}; mocha.rootHooks({afterEach}); expect(mocha.suite.afterEach, 'to have a call satisfying', [ @@ -1210,8 +1210,8 @@ describe('Mocha', function() { }); }); - describe('when provided multiple "before all" hooks', function() { - it('should attach each to the root suite', function() { + describe('when provided multiple "before all" hooks', function () { + it('should attach each to the root suite', function () { const beforeAll = [() => {}, () => {}]; mocha.rootHooks({beforeAll}); expect(mocha.suite.beforeAll, 'to have calls satisfying', [ @@ -1221,8 +1221,8 @@ describe('Mocha', function() { }); }); - describe('when provided multiple "before each" hooks', function() { - it('should attach each to the root suite', function() { + describe('when provided multiple "before each" hooks', function () { + it('should attach each to the root suite', function () { const beforeEach = [() => {}, () => {}]; mocha.rootHooks({beforeEach}); expect(mocha.suite.beforeEach, 'to have calls satisfying', [ @@ -1232,8 +1232,8 @@ describe('Mocha', function() { }); }); - describe('when provided multiple "after all" hooks', function() { - it('should attach each to the root suite', function() { + describe('when provided multiple "after all" hooks', function () { + it('should attach each to the root suite', function () { const afterAll = [() => {}, () => {}]; mocha.rootHooks({afterAll}); expect(mocha.suite.afterAll, 'to have calls satisfying', [ @@ -1243,8 +1243,8 @@ describe('Mocha', function() { }); }); - describe('when provided multiple "after each" hooks', function() { - it('should attach each to the root suite', function() { + describe('when provided multiple "after each" hooks', function () { + it('should attach each to the root suite', function () { const afterEach = [() => {}, () => {}]; mocha.rootHooks({afterEach}); expect(mocha.suite.afterEach, 'to have calls satisfying', [ diff --git a/test/unit/overspecified-async.spec.js b/test/unit/overspecified-async.spec.js index 43a69881cf..0f9b6c9ff5 100644 --- a/test/unit/overspecified-async.spec.js +++ b/test/unit/overspecified-async.spec.js @@ -1,7 +1,7 @@ 'use strict'; -describe('overspecified asynchronous resolution method', function() { - it('should fail when multiple methods are used', function(done) { +describe('overspecified asynchronous resolution method', function () { + it('should fail when multiple methods are used', function (done) { setTimeout(done, 0); // uncomment diff --git a/test/unit/parse-query.spec.js b/test/unit/parse-query.spec.js index c86e92dd1f..d3be471bca 100644 --- a/test/unit/parse-query.spec.js +++ b/test/unit/parse-query.spec.js @@ -2,8 +2,8 @@ var parseQuery = require('../../lib/browser/parse-query'); -describe('parseQuery()', function() { - it('should get queryString and return key-value object', function() { +describe('parseQuery()', function () { + it('should get queryString and return key-value object', function () { expect(parseQuery('?foo=1&bar=2&baz=3'), 'to equal', { foo: '1', bar: '2', @@ -17,7 +17,7 @@ describe('parseQuery()', function() { }); }); - it('should parse "+" as a space', function() { + it('should parse "+" as a space', function () { expect(parseQuery('?grep=foo+bar'), 'to equal', {grep: 'foo bar'}); }); }); diff --git a/test/unit/plugin-loader.spec.js b/test/unit/plugin-loader.spec.js index 78d2debdbb..80fbca5724 100644 --- a/test/unit/plugin-loader.spec.js +++ b/test/unit/plugin-loader.spec.js @@ -2,22 +2,20 @@ const PluginLoader = require('../../lib/plugin-loader'); const sinon = require('sinon'); -const { - INVALID_PLUGIN_DEFINITION, - INVALID_PLUGIN_IMPLEMENTATION -} = require('../../lib/errors').constants; - -describe('plugin module', function() { - describe('class PluginLoader', function() { - describe('constructor', function() { - describe('when passed no options', function() { - it('should populate a registry of built-in plugins', function() { +const {INVALID_PLUGIN_DEFINITION, INVALID_PLUGIN_IMPLEMENTATION} = + require('../../lib/errors').constants; + +describe('plugin module', function () { + describe('class PluginLoader', function () { + describe('constructor', function () { + describe('when passed no options', function () { + it('should populate a registry of built-in plugins', function () { expect(new PluginLoader().registered.has('mochaHooks'), 'to be true'); }); }); - describe('when passed custom plugins', function() { - it('should register the custom plugins', function() { + describe('when passed custom plugins', function () { + it('should register the custom plugins', function () { const plugin = {exportName: 'mochaBananaPhone'}; expect( new PluginLoader({pluginDefs: [plugin]}).registered, @@ -27,8 +25,8 @@ describe('plugin module', function() { }); }); - describe('when passed ignored plugins', function() { - it('should retain a list of ignored plugins', function() { + describe('when passed ignored plugins', function () { + it('should retain a list of ignored plugins', function () { expect( new PluginLoader({ ignore: ['elephantInRoom'] @@ -40,26 +38,26 @@ describe('plugin module', function() { }); }); - describe('static method', function() { - describe('create()', function() { - it('should return a PluginLoader instance', function() { + describe('static method', function () { + describe('create()', function () { + it('should return a PluginLoader instance', function () { expect(PluginLoader.create(), 'to be a', PluginLoader); }); }); }); - describe('instance method', function() { + describe('instance method', function () { let pluginLoader; - beforeEach(function() { + beforeEach(function () { pluginLoader = PluginLoader.create({ ignore: ['elephantInRoom'] }); }); - describe('register()', function() { - describe('when the plugin export name is not in use', function() { - it('should not throw', function() { + describe('register()', function () { + describe('when the plugin export name is not in use', function () { + it('should not throw', function () { expect( () => pluginLoader.register({exportName: 'butts'}), 'not to throw' @@ -67,8 +65,8 @@ describe('plugin module', function() { }); }); - describe('when the plugin export name is already in use', function() { - it('should throw', function() { + describe('when the plugin export name is already in use', function () { + it('should throw', function () { const pluginDef = {exportName: 'butts'}; pluginLoader.register(pluginDef); expect(() => pluginLoader.register(pluginDef), 'to throw', { @@ -78,18 +76,18 @@ describe('plugin module', function() { }); }); - describe('when the plugin export name is ignored', function() { + describe('when the plugin export name is ignored', function () { let pluginDef; - beforeEach(function() { + beforeEach(function () { pluginDef = {exportName: 'elephantInRoom'}; }); - it('should not throw', function() { + it('should not throw', function () { expect(() => pluginLoader.register(pluginDef), 'not to throw'); }); - it('should not register the plugin', function() { + it('should not register the plugin', function () { pluginLoader.register(pluginDef); expect( pluginLoader.registered, @@ -99,16 +97,16 @@ describe('plugin module', function() { }); }); - describe('when passed a falsy parameter', function() { - it('should throw', function() { + describe('when passed a falsy parameter', function () { + it('should throw', function () { expect(() => pluginLoader.register(), 'to throw', { code: INVALID_PLUGIN_DEFINITION }); }); }); - describe('when passed a non-object parameter', function() { - it('should throw', function() { + describe('when passed a non-object parameter', function () { + it('should throw', function () { expect(() => pluginLoader.register(1), 'to throw', { code: INVALID_PLUGIN_DEFINITION, pluginDef: 1 @@ -116,8 +114,8 @@ describe('plugin module', function() { }); }); - describe('when passed a definition w/o an exportName', function() { - it('should throw', function() { + describe('when passed a definition w/o an exportName', function () { + it('should throw', function () { const pluginDef = {foo: 'bar'}; expect(() => pluginLoader.register(pluginDef), 'to throw', { code: INVALID_PLUGIN_DEFINITION, @@ -127,21 +125,21 @@ describe('plugin module', function() { }); }); - describe('load()', function() { + describe('load()', function () { let pluginLoader; - beforeEach(function() { + beforeEach(function () { pluginLoader = PluginLoader.create(); }); - describe('when called with a falsy value', function() { - it('should return false', function() { + describe('when called with a falsy value', function () { + it('should return false', function () { expect(pluginLoader.load(), 'to be false'); }); }); - describe('when called with an object containing no recognized plugin', function() { - it('should return false', function() { + describe('when called with an object containing no recognized plugin', function () { + it('should return false', function () { // also it should not throw expect( pluginLoader.load({mochaBananaPhone: () => {}}), @@ -150,11 +148,11 @@ describe('plugin module', function() { }); }); - describe('when called with an object containing a recognized plugin', function() { + describe('when called with an object containing a recognized plugin', function () { let plugin; let pluginLoader; - beforeEach(function() { + beforeEach(function () { plugin = { exportName: 'mochaBananaPhone', validate: sinon.spy() @@ -162,12 +160,12 @@ describe('plugin module', function() { pluginLoader = PluginLoader.create({pluginDefs: [plugin]}); }); - it('should return true', function() { + it('should return true', function () { const func = () => {}; expect(pluginLoader.load({mochaBananaPhone: func}), 'to be true'); }); - it('should retain the value of any matching property in its mapping', function() { + it('should retain the value of any matching property in its mapping', function () { const func = () => {}; pluginLoader.load({mochaBananaPhone: func}); expect( @@ -177,7 +175,7 @@ describe('plugin module', function() { ); }); - it('should call the associated validator, if present', function() { + it('should call the associated validator, if present', function () { const func = () => {}; pluginLoader.load({mochaBananaPhone: func}); expect(plugin.validate, 'was called once'); @@ -185,12 +183,12 @@ describe('plugin module', function() { }); }); - describe('load()', function() { + describe('load()', function () { let pluginLoader; let fooPlugin; let barPlugin; - beforeEach(function() { + beforeEach(function () { fooPlugin = { exportName: 'foo', validate: sinon.stub() @@ -205,40 +203,40 @@ describe('plugin module', function() { }); }); - describe('when passed a falsy or non-object value', function() { - it('should return false', function() { + describe('when passed a falsy or non-object value', function () { + it('should return false', function () { expect(pluginLoader.load(), 'to be false'); }); - it('should not call a validator', function() { + it('should not call a validator', function () { expect([fooPlugin, barPlugin], 'to have items satisfying', { validate: expect.it('was not called') }); }); }); - describe('when passed an object value', function() { - describe('when no keys match any known named exports', function() { + describe('when passed an object value', function () { + describe('when no keys match any known named exports', function () { let retval; - beforeEach(function() { + beforeEach(function () { retval = pluginLoader.load({butts: () => {}}); }); - it('should return false', function() { + it('should return false', function () { expect(retval, 'to be false'); }); }); - describe('when a key matches a known named export', function() { + describe('when a key matches a known named export', function () { let retval; let impl; - beforeEach(function() { + beforeEach(function () { impl = sinon.stub(); }); - it('should call the associated validator', function() { + it('should call the associated validator', function () { retval = pluginLoader.load({foo: impl}); expect(fooPlugin.validate, 'to have a call satisfying', [ @@ -246,21 +244,21 @@ describe('plugin module', function() { ]).and('was called once'); }); - it('should not call validators whose keys were not found', function() { + it('should not call validators whose keys were not found', function () { retval = pluginLoader.load({foo: impl}); expect(barPlugin.validate, 'was not called'); }); - describe('when the value passes the associated validator', function() { - beforeEach(function() { + describe('when the value passes the associated validator', function () { + beforeEach(function () { retval = pluginLoader.load({foo: impl}); }); - it('should return true', function() { + it('should return true', function () { expect(retval, 'to be true'); }); - it('should add the implementation to the internal mapping', function() { + it('should add the implementation to the internal mapping', function () { expect( pluginLoader.loaded, 'to satisfy', @@ -268,7 +266,7 @@ describe('plugin module', function() { ); }); - it('should not add an implementation of plugins not present', function() { + it('should not add an implementation of plugins not present', function () { expect( pluginLoader.loaded, 'to satisfy', @@ -277,8 +275,8 @@ describe('plugin module', function() { }); }); - describe('when the value does not pass the associated validator', function() { - it('should throw', function() { + describe('when the value does not pass the associated validator', function () { + it('should throw', function () { expect(() => pluginLoader.load({foo: 'ERROR'}), 'to throw'); }); }); @@ -286,13 +284,13 @@ describe('plugin module', function() { }); }); - describe('finalize()', function() { + describe('finalize()', function () { let pluginLoader; let fooPlugin; let barPlugin; let bazPlugin; - beforeEach(function() { + beforeEach(function () { fooPlugin = { exportName: 'foo', optionName: 'fooOption', @@ -313,25 +311,25 @@ describe('plugin module', function() { }); }); - describe('when no plugins have been loaded', function() { - it('should return an empty map', async function() { + describe('when no plugins have been loaded', function () { + it('should return an empty map', async function () { return expect(pluginLoader.finalize(), 'to be fulfilled with', {}); }); }); - describe('when a plugin has one or more implementations', function() { - beforeEach(function() { + describe('when a plugin has one or more implementations', function () { + beforeEach(function () { pluginLoader.load({foo: sinon.stub()}); pluginLoader.load({foo: sinon.stub()}); }); - it('should return an object map using `optionName` key for each registered plugin', async function() { + it('should return an object map using `optionName` key for each registered plugin', async function () { return expect(pluginLoader.finalize(), 'to be fulfilled with', { fooOption: ['FOO', 'FOO'] }); }); - it('should omit unused plugins', async function() { + it('should omit unused plugins', async function () { pluginLoader.load({bar: sinon.stub()}); return expect(pluginLoader.finalize(), 'to be fulfilled with', { fooOption: ['FOO', 'FOO'], @@ -340,8 +338,8 @@ describe('plugin module', function() { }); }); - describe('when a plugin has no "finalize" function', function() { - it('should return an array of raw implementations', function() { + describe('when a plugin has no "finalize" function', function () { + it('should return an array of raw implementations', function () { pluginLoader.load({baz: 'polar bears'}); return expect(pluginLoader.finalize(), 'to be fulfilled with', { baz: ['polar bears'] @@ -352,42 +350,42 @@ describe('plugin module', function() { }); }); - describe('root hooks plugin 🎣', function() { + describe('root hooks plugin 🎣', function () { let pluginLoader; - beforeEach(function() { + beforeEach(function () { pluginLoader = PluginLoader.create(); }); - describe('when impl is an array', function() { - it('should fail validation', function() { + describe('when impl is an array', function () { + it('should fail validation', function () { expect(() => pluginLoader.load({mochaHooks: []}), 'to throw', { code: INVALID_PLUGIN_IMPLEMENTATION }); }); }); - describe('when impl is a primitive', function() { - it('should fail validation', function() { + describe('when impl is a primitive', function () { + it('should fail validation', function () { expect(() => pluginLoader.load({mochaHooks: 'nuts'}), 'to throw', { code: INVALID_PLUGIN_IMPLEMENTATION }); }); }); - describe('when impl is a function', function() { - it('should pass validation', function() { + describe('when impl is a function', function () { + it('should pass validation', function () { expect(pluginLoader.load({mochaHooks: sinon.stub()}), 'to be true'); }); }); - describe('when impl is an object of functions', function() { + describe('when impl is an object of functions', function () { // todo: hook name validation? it('should pass validation'); }); - describe('when a loaded impl is finalized', function() { - it('should flatten the implementations', async function() { + describe('when a loaded impl is finalized', function () { + it('should flatten the implementations', async function () { function a() {} function b() {} function d() {} @@ -430,24 +428,24 @@ describe('plugin module', function() { }); }); - describe('global fixtures plugin', function() { + describe('global fixtures plugin', function () { let pluginLoader; - beforeEach(function() { + beforeEach(function () { pluginLoader = PluginLoader.create(); }); - describe('global setup', function() { - describe('when an implementation is a primitive', function() { - it('should fail validation', function() { + describe('global setup', function () { + describe('when an implementation is a primitive', function () { + it('should fail validation', function () { expect( () => pluginLoader.load({mochaGlobalSetup: 'nuts'}), 'to throw' ); }); }); - describe('when an implementation is an array of primitives', function() { - it('should fail validation', function() { + describe('when an implementation is an array of primitives', function () { + it('should fail validation', function () { expect( () => pluginLoader.load({mochaGlobalSetup: ['nuts']}), 'to throw' @@ -455,8 +453,8 @@ describe('plugin module', function() { }); }); - describe('when an implementation is a function', function() { - it('should pass validation', function() { + describe('when an implementation is a function', function () { + it('should pass validation', function () { expect( pluginLoader.load({mochaGlobalSetup: sinon.stub()}), 'to be true' @@ -464,8 +462,8 @@ describe('plugin module', function() { }); }); - describe('when an implementation is an array of functions', function() { - it('should pass validation', function() { + describe('when an implementation is an array of functions', function () { + it('should pass validation', function () { expect( pluginLoader.load({mochaGlobalSetup: [sinon.stub()]}), 'to be true' @@ -474,17 +472,17 @@ describe('plugin module', function() { }); }); - describe('global teardown', function() { - describe('when an implementation is a primitive', function() { - it('should fail validation', function() { + describe('global teardown', function () { + describe('when an implementation is a primitive', function () { + it('should fail validation', function () { expect( () => pluginLoader.load({mochaGlobalTeardown: 'nuts'}), 'to throw' ); }); }); - describe('when an implementation is an array of primitives', function() { - it('should fail validation', function() { + describe('when an implementation is an array of primitives', function () { + it('should fail validation', function () { expect( () => pluginLoader.load({mochaGlobalTeardown: ['nuts']}), 'to throw' @@ -492,8 +490,8 @@ describe('plugin module', function() { }); }); - describe('when an implementation is a function', function() { - it('should pass validation', function() { + describe('when an implementation is a function', function () { + it('should pass validation', function () { expect( pluginLoader.load({mochaGlobalTeardown: sinon.stub()}), 'to be true' @@ -501,8 +499,8 @@ describe('plugin module', function() { }); }); - describe('when an implementation is an array of functions', function() { - it('should pass validation', function() { + describe('when an implementation is an array of functions', function () { + it('should pass validation', function () { expect( pluginLoader.load({mochaGlobalTeardown: [sinon.stub()]}), 'to be true' diff --git a/test/unit/required-tokens.spec.js b/test/unit/required-tokens.spec.js index bb9f05f44e..836e664d4d 100644 --- a/test/unit/required-tokens.spec.js +++ b/test/unit/required-tokens.spec.js @@ -3,8 +3,8 @@ const assert = require('assert'); const {describe, it} = require('../..'); -describe('using imported "describe"', function() { - it('using imported "it"', function(done) { +describe('using imported "describe"', function () { + it('using imported "it"', function (done) { assert.ok(true); done(); }); diff --git a/test/unit/root.spec.js b/test/unit/root.spec.js index 00040e5c32..9adbaf9c61 100644 --- a/test/unit/root.spec.js +++ b/test/unit/root.spec.js @@ -2,12 +2,12 @@ var calls = []; -before(function() { +before(function () { calls.push('before'); }); -describe('root', function() { - it('should be a valid suite', function() { +describe('root', function () { + it('should be a valid suite', function () { expect(calls, 'to equal', ['before']); }); }); diff --git a/test/unit/runnable.spec.js b/test/unit/runnable.spec.js index d4975d4ffe..b4ae296478 100644 --- a/test/unit/runnable.spec.js +++ b/test/unit/runnable.spec.js @@ -7,135 +7,135 @@ var sinon = require('sinon'); const {TIMEOUT} = require('../../lib/errors').constants; var STATE_FAILED = Runnable.constants.STATE_FAILED; -describe('Runnable(title, fn)', function() { - describe('#timeout(ms)', function() { +describe('Runnable(title, fn)', function () { + describe('#timeout(ms)', function () { var DISABLED_TIMEOUTS = 0; var MAX_TIMEOUT = 2147483647; // INT_MAX (32-bit signed integer) - describe('when value is less than lower bound', function() { - it('should clamp to lower bound given numeric', function() { + describe('when value is less than lower bound', function () { + it('should clamp to lower bound given numeric', function () { var run = new Runnable(); run.timeout(-1); expect(run.timeout(), 'to be', DISABLED_TIMEOUTS); }); - it('should clamp to lower bound given timestamp', function() { + it('should clamp to lower bound given timestamp', function () { var run = new Runnable(); run.timeout('-1 ms'); expect(run.timeout(), 'to be', DISABLED_TIMEOUTS); }); }); - describe('when value is equal to lower bound', function() { + describe('when value is equal to lower bound', function () { var run; - beforeEach(function() { + beforeEach(function () { run = new Runnable(); run.timeout(DISABLED_TIMEOUTS); }); - describe('given numeric value', function() { - it('should set the timeout value to disabled', function() { + describe('given numeric value', function () { + it('should set the timeout value to disabled', function () { expect(run.timeout(), 'to be', DISABLED_TIMEOUTS); }); }); - describe('given string timestamp', function() { - it('should set the timeout value to disabled', function() { + describe('given string timestamp', function () { + it('should set the timeout value to disabled', function () { expect(run.timeout(), 'to be', DISABLED_TIMEOUTS); }); }); }); - describe('when value is within `setTimeout` bounds', function() { + describe('when value is within `setTimeout` bounds', function () { var run; var timeout = 1000; - beforeEach(function() { + beforeEach(function () { run = new Runnable(); run.timeout(timeout); }); - describe('given numeric value', function() { - it('should set the timeout value', function() { + describe('given numeric value', function () { + it('should set the timeout value', function () { expect(run.timeout(), 'to be', timeout); }); }); - describe('given string timestamp', function() { - it('should set the timeout value', function() { + describe('given string timestamp', function () { + it('should set the timeout value', function () { expect(run.timeout(), 'to be', timeout); }); }); }); - describe('when value is equal to upper bound', function() { + describe('when value is equal to upper bound', function () { var run; - beforeEach(function() { + beforeEach(function () { run = new Runnable(); run.timeout(MAX_TIMEOUT); }); - describe('given numeric value', function() { - it('should set the disabled timeout value', function() { + describe('given numeric value', function () { + it('should set the disabled timeout value', function () { expect(run.timeout(), 'to be', 0); }); }); }); - describe('when value is out-of-bounds', function() { + describe('when value is out-of-bounds', function () { var run; var timeout = MAX_TIMEOUT + 1; - beforeEach(function() { + beforeEach(function () { run = new Runnable(); run.timeout(timeout); }); - describe('given numeric value', function() { - it('should set the disabled timeout value', function() { + describe('given numeric value', function () { + it('should set the disabled timeout value', function () { expect(run.timeout(), 'to be', 0); }); }); }); }); - describe('#slow(ms)', function() { + describe('#slow(ms)', function () { var run; - beforeEach(function() { + beforeEach(function () { run = new Runnable(); }); - it('should set the slow threshold', function() { + it('should set the slow threshold', function () { run.slow(100); expect(run.slow(), 'to be', 100); }); - it('should not set the slow threshold if the parameter is not passed', function() { + it('should not set the slow threshold if the parameter is not passed', function () { run.slow(); expect(run.slow(), 'to be', 75); }); - it('should not set the slow threshold if the parameter is undefined', function() { + it('should not set the slow threshold if the parameter is undefined', function () { run.slow(undefined); expect(run.slow(), 'to be', 75); }); - describe('when passed a time-formatted string', function() { - it('should convert to ms', function() { + describe('when passed a time-formatted string', function () { + it('should convert to ms', function () { run.slow('1s'); expect(run.slow(), 'to be', 1000); }); }); }); - describe('#reset', function() { + describe('#reset', function () { var run; - beforeEach(function() { + beforeEach(function () { run = new Runnable(); }); - it('should reset current run state', function() { + it('should reset current run state', function () { run.timedOut = true; run._currentRetry = 5; run.pending = true; @@ -151,14 +151,14 @@ describe('Runnable(title, fn)', function() { }); }); - describe('.title', function() { - it('should be present', function() { + describe('.title', function () { + it('should be present', function () { expect(new Runnable('foo').title, 'to be', 'foo'); }); }); - describe('.titlePath()', function() { - it("returns the concatenation of the parent's title path and runnable's title", function() { + describe('.titlePath()', function () { + it("returns the concatenation of the parent's title path and runnable's title", function () { var runnable = new Runnable('bar'); runnable.parent = new Suite('foo'); expect( @@ -169,62 +169,62 @@ describe('Runnable(title, fn)', function() { }); }); - describe('when arity >= 1', function() { + describe('when arity >= 1', function () { var run; - beforeEach(function() { - run = new Runnable('foo', function(done) {}); + beforeEach(function () { + run = new Runnable('foo', function (done) {}); }); - it('should be .async', function() { + it('should be .async', function () { expect(run.async, 'to be', 1); }); - it('should not be .sync', function() { + it('should not be .sync', function () { expect(run.sync, 'to be false'); }); }); - describe('when arity == 0', function() { + describe('when arity == 0', function () { var run; - beforeEach(function() { - run = new Runnable('foo', function() {}); + beforeEach(function () { + run = new Runnable('foo', function () {}); }); - it('should not be .async', function() { + it('should not be .async', function () { expect(run.async, 'to be', 0); }); - it('should be .sync', function() { + it('should be .sync', function () { expect(run.sync, 'to be true'); }); }); - describe('#globals', function() { - it('should allow for whitelisting globals', function() { - var runnable = new Runnable('foo', function() {}); + describe('#globals', function () { + it('should allow for whitelisting globals', function () { + var runnable = new Runnable('foo', function () {}); runnable.globals(['foobar']); expect(runnable._allowedGlobals, 'to equal', ['foobar']); }); }); - describe('#retries(n)', function() { - it('should set the number of retries', function() { + describe('#retries(n)', function () { + it('should set the number of retries', function () { var run = new Runnable(); run.retries(1); expect(run.retries(), 'to be', 1); }); }); - describe('.run(fn)', function() { - describe('when .pending', function() { - it('should not invoke the callback', function(done) { + describe('.run(fn)', function () { + describe('when .pending', function () { + it('should not invoke the callback', function (done) { var spy = sinon.spy(); var runnable = new Runnable('foo', spy); runnable.pending = true; - runnable.run(function(err) { + runnable.run(function (err) { if (err) { return done(err); } @@ -234,13 +234,13 @@ describe('Runnable(title, fn)', function() { }); }); - describe('when sync', function() { - describe('without error', function() { - it('should invoke the callback', function(done) { + describe('when sync', function () { + describe('without error', function () { + it('should invoke the callback', function (done) { var spy = sinon.spy(); var runnable = new Runnable('foo', spy); - runnable.run(function(err) { + runnable.run(function (err) { if (err) { return done(err); } @@ -251,12 +251,12 @@ describe('Runnable(title, fn)', function() { }); }); - describe('when an exception is thrown', function() { - it('should invoke the callback with error', function(done) { + describe('when an exception is thrown', function () { + it('should invoke the callback with error', function (done) { var stub = sinon.stub().throws('Error', 'fail'); var runnable = new Runnable('foo', stub); - runnable.run(function(err) { + runnable.run(function (err) { expect(err.message, 'to be', 'fail'); expect(stub, 'was called'); done(); @@ -264,57 +264,57 @@ describe('Runnable(title, fn)', function() { }); }); - describe('when an exception is thrown and is allowed to remain uncaught', function() { - it('throws an error when it is allowed', function() { + describe('when an exception is thrown and is allowed to remain uncaught', function () { + it('throws an error when it is allowed', function () { var stub = sinon.stub().throws('Error', 'fail'); var runnable = new Runnable('foo', stub); runnable.allowUncaught = true; function fail() { - runnable.run(function() {}); + runnable.run(function () {}); } expect(fail, 'to throw', 'fail'); }); }); }); - describe('when timeouts are disabled', function() { - it('should not error with timeout', function(done) { - var runnable = new Runnable('foo', function(done) { - setTimeout(function() { + describe('when timeouts are disabled', function () { + it('should not error with timeout', function (done) { + var runnable = new Runnable('foo', function (done) { + setTimeout(function () { setTimeout(done); }, 2); }); runnable.timeout(1); runnable.timeout(0); - runnable.run(function(err) { + runnable.run(function (err) { expect(err, 'to be falsy'); done(); }); }); }); - describe('when async', function() { - describe('without error', function() { - it('should invoke the callback', function(done) { - var runnable = new Runnable('foo', function(done) { + describe('when async', function () { + describe('without error', function () { + it('should invoke the callback', function (done) { + var runnable = new Runnable('foo', function (done) { setTimeout(done); }); - runnable.run(function(err) { + runnable.run(function (err) { expect(err, 'to be falsy'); done(); }); }); }); - describe('when the callback is invoked several times', function() { - describe('without an error', function() { - it('should emit a single "error" event', function(done) { + describe('when the callback is invoked several times', function () { + describe('without an error', function () { + it('should emit a single "error" event', function (done) { var callbackSpy = sinon.spy(); var errorSpy = sinon.spy(); - var runnable = new Runnable('foo', function(done) { + var runnable = new Runnable('foo', function (done) { process.nextTick(done); setTimeout(done); setTimeout(done); @@ -323,8 +323,8 @@ describe('Runnable(title, fn)', function() { // XXX too many diff assertions and very flimsy assertion that this // event was only emitted once. think of a better way. - runnable.on('error', errorSpy).on('error', function(err) { - process.nextTick(function() { + runnable.on('error', errorSpy).on('error', function (err) { + process.nextTick(function () { expect(errorSpy, 'was called times', 1); expect( err.message, @@ -340,12 +340,12 @@ describe('Runnable(title, fn)', function() { }); }); - describe('with an error', function() { - it('should emit a single "error" event', function(done) { + describe('with an error', function () { + it('should emit a single "error" event', function (done) { var callbackSpy = sinon.spy(); var errorSpy = sinon.spy(); - var runnable = new Runnable('foo', function(done) { + var runnable = new Runnable('foo', function (done) { done(new Error('fail')); setTimeout(done); done(new Error('fail')); @@ -355,8 +355,8 @@ describe('Runnable(title, fn)', function() { // XXX too many diff assertions and very flimsy assertion that this // event was only emitted once. think of a better way. - runnable.on('error', errorSpy).on('error', function(err) { - process.nextTick(function() { + runnable.on('error', errorSpy).on('error', function (err) { + process.nextTick(function () { expect(errorSpy, 'was called times', 1); expect( err.message, @@ -373,69 +373,69 @@ describe('Runnable(title, fn)', function() { }); }); - describe('when an exception is thrown', function() { - it('should invoke the callback', function(done) { + describe('when an exception is thrown', function () { + it('should invoke the callback', function (done) { var runnable = new Runnable( 'foo', sinon.stub().throws('Error', 'fail') ); - runnable.run(function(err) { + runnable.run(function (err) { expect(err.message, 'to be', 'fail'); done(); }); }); - it('should not throw its own exception if passed a non-object', function(done) { - var runnable = new Runnable('foo', function(done) { + it('should not throw its own exception if passed a non-object', function (done) { + var runnable = new Runnable('foo', function (done) { /* eslint no-throw-literal: off */ throw null; }); - runnable.run(function(err) { + runnable.run(function (err) { expect(err.message, 'to be', Runnable.toValueOrError().message); done(); }); }); }); - describe('when an exception is thrown and is allowed to remain uncaught', function() { - it('throws an error when it is allowed', function(done) { - var runnable = new Runnable('foo', function(done) { + describe('when an exception is thrown and is allowed to remain uncaught', function () { + it('throws an error when it is allowed', function (done) { + var runnable = new Runnable('foo', function (done) { throw new Error('fail'); }); runnable.allowUncaught = true; function fail() { - runnable.run(function() {}); + runnable.run(function () {}); } expect(fail, 'to throw', 'fail'); done(); }); }); - describe('when an error is passed', function() { - it('should invoke the callback', function(done) { - var runnable = new Runnable('foo', function(done) { + describe('when an error is passed', function () { + it('should invoke the callback', function (done) { + var runnable = new Runnable('foo', function (done) { done(new Error('fail')); }); - runnable.run(function(err) { + runnable.run(function (err) { expect(err.message, 'to be', 'fail'); done(); }); }); }); - describe('when done() is invoked with a non-Error object', function() { - it('should invoke the callback', function(done) { - var runnable = new Runnable('foo', function(done) { + describe('when done() is invoked with a non-Error object', function () { + it('should invoke the callback', function (done) { + var runnable = new Runnable('foo', function (done) { done({ error: 'Test error' }); }); - runnable.run(function(err) { + runnable.run(function (err) { expect( err.message, 'to be', @@ -446,13 +446,13 @@ describe('Runnable(title, fn)', function() { }); }); - describe('when done() is invoked with a string', function() { - it('should invoke the callback', function(done) { - var runnable = new Runnable('foo', function(done) { + describe('when done() is invoked with a string', function () { + it('should invoke the callback', function (done) { + var runnable = new Runnable('foo', function (done) { done('Test error'); }); - runnable.run(function(err) { + runnable.run(function (err) { expect( err.message, 'to be', @@ -463,21 +463,21 @@ describe('Runnable(title, fn)', function() { }); }); - it('should allow updating the timeout', function(done) { + it('should allow updating the timeout', function (done) { var spy = sinon.spy(); - var runnable = new Runnable('foo', function(done) { + var runnable = new Runnable('foo', function (done) { setTimeout(spy, 1); setTimeout(spy, 100); }); runnable.timeout(50); - runnable.run(function(err) { + runnable.run(function (err) { expect(err, 'to be truthy'); expect(spy, 'was called times', 1); done(); }); }); - it('should allow a timeout of 0', function(done) { + it('should allow a timeout of 0', function (done) { const runnable = new Runnable('foo', () => {}); runnable.timeout(0); runnable.run(err => { @@ -487,104 +487,104 @@ describe('Runnable(title, fn)', function() { }); }); - describe('when fn returns a promise', function() { - describe('when the promise is fulfilled with no value', function() { + describe('when fn returns a promise', function () { + describe('when the promise is fulfilled with no value', function () { var fulfilledPromise = { - then: function(fulfilled) { + then: function (fulfilled) { setTimeout(fulfilled); } }; - it('should invoke the callback', function(done) { - var runnable = new Runnable('foo', function() { + it('should invoke the callback', function (done) { + var runnable = new Runnable('foo', function () { return fulfilledPromise; }); - runnable.run(function(err) { + runnable.run(function (err) { expect(err, 'to be falsy'); done(); }); }); }); - describe('when the promise is fulfilled with a value', function() { + describe('when the promise is fulfilled with a value', function () { var fulfilledPromise = { - then: function(fulfilled, rejected) { - setTimeout(function() { + then: function (fulfilled, rejected) { + setTimeout(function () { fulfilled({}); }); } }; - it('should invoke the callback', function(done) { - var runnable = new Runnable('foo', function() { + it('should invoke the callback', function (done) { + var runnable = new Runnable('foo', function () { return fulfilledPromise; }); - runnable.run(function(err) { + runnable.run(function (err) { expect(err, 'to be falsy'); done(); }); }); }); - describe('when the promise is rejected', function() { + describe('when the promise is rejected', function () { var expectedErr = new Error('fail'); var rejectedPromise = { - then: function(fulfilled, rejected) { - setTimeout(function() { + then: function (fulfilled, rejected) { + setTimeout(function () { rejected(expectedErr); }); } }; - it('should invoke the callback', function(done) { - var runnable = new Runnable('foo', function() { + it('should invoke the callback', function (done) { + var runnable = new Runnable('foo', function () { return rejectedPromise; }); - runnable.run(function(err) { + runnable.run(function (err) { expect(err, 'to be', expectedErr); done(); }); }); }); - describe('when the promise is rejected without a reason', function() { + describe('when the promise is rejected without a reason', function () { var expectedErr = new Error('Promise rejected with no or falsy reason'); var rejectedPromise = { - then: function(fulfilled, rejected) { - setTimeout(function() { + then: function (fulfilled, rejected) { + setTimeout(function () { rejected(); }); } }; - it('should invoke the callback', function(done) { - var runnable = new Runnable('foo', function() { + it('should invoke the callback', function (done) { + var runnable = new Runnable('foo', function () { return rejectedPromise; }); - runnable.run(function(err) { + runnable.run(function (err) { expect(err.message, 'to be', expectedErr.message); done(); }); }); }); - describe('when the promise takes too long to settle', function() { + describe('when the promise takes too long to settle', function () { var foreverPendingPromise = { - then: function() {} + then: function () {} }; - it('should throw the timeout error', function(done) { - var runnable = new Runnable('foo', function() { + it('should throw the timeout error', function (done) { + var runnable = new Runnable('foo', function () { return foreverPendingPromise; }); runnable.file = '/some/path'; runnable.timeout(10); - runnable.run(function(err) { + runnable.run(function (err) { expect(err, 'to satisfy', {code: TIMEOUT, timeout: 10}); done(); }); @@ -592,9 +592,9 @@ describe('Runnable(title, fn)', function() { }); }); - describe('when fn returns a non-promise', function() { - it('should invoke the callback', function(done) { - var runnable = new Runnable('foo', function() { + describe('when fn returns a non-promise', function () { + it('should invoke the callback', function (done) { + var runnable = new Runnable('foo', function () { return { then: 'i ran my tests' }; @@ -604,16 +604,16 @@ describe('Runnable(title, fn)', function() { }); }); - describe('if timed-out', function() { - it('should ignore call to `done` and not execute callback again', function(done) { - var runnable = new Runnable('foo', function(done) { + describe('if timed-out', function () { + it('should ignore call to `done` and not execute callback again', function (done) { + var runnable = new Runnable('foo', function (done) { setTimeout(done, 20); }); runnable.timeout(10); - runnable.run(function(err) { + runnable.run(function (err) { expect(err, 'to satisfy', {code: TIMEOUT, timeout: 10}); // timedOut is set *after* this callback is executed - process.nextTick(function() { + process.nextTick(function () { expect(runnable.timedOut, 'to be truthy'); done(); }); @@ -621,29 +621,29 @@ describe('Runnable(title, fn)', function() { }); }); - describe('if async', function() { - it('this.skip() should set runnable to pending', function(done) { - var runnable = new Runnable('foo', function(done) { + describe('if async', function () { + it('this.skip() should set runnable to pending', function (done) { + var runnable = new Runnable('foo', function (done) { // normally "this" but it gets around having to muck with a context runnable.skip(); }); - runnable.run(function(err) { + runnable.run(function (err) { expect(err, 'to be undefined'); expect(runnable.pending, 'to be true'); done(); }); }); - it('this.skip() should halt synchronous execution', function(done) { + it('this.skip() should halt synchronous execution', function (done) { var aborted = true; - var runnable = new Runnable('foo', function(done) { + var runnable = new Runnable('foo', function (done) { // normally "this" but it gets around having to muck with a context runnable.skip(); /* istanbul ignore next */ aborted = false; }); - runnable.run(function() { - process.nextTick(function() { + runnable.run(function () { + process.nextTick(function () { expect(aborted, 'to be true'); done(); }); @@ -651,11 +651,11 @@ describe('Runnable(title, fn)', function() { }); }); - describe('when fn is not a function', function() { - it('should throw an error', function() { + describe('when fn is not a function', function () { + it('should throw an error', function () { var runnable = new Runnable('foo', 4); - runnable.run(function(err) { + runnable.run(function (err) { expect( err.message, 'to be', @@ -666,68 +666,68 @@ describe('Runnable(title, fn)', function() { }); }); - describe('#isFailed()', function() { - it('should return `true` if test has not failed', function() { - var runnable = new Runnable('foo', function() {}); + describe('#isFailed()', function () { + it('should return `true` if test has not failed', function () { + var runnable = new Runnable('foo', function () {}); // runner sets the state - runnable.run(function() { + runnable.run(function () { expect(runnable.isFailed(), 'to be false'); }); }); - it('should return `true` if test has failed', function() { - var runnable = new Runnable('foo', function() {}); + it('should return `true` if test has failed', function () { + var runnable = new Runnable('foo', function () {}); // runner sets the state runnable.state = STATE_FAILED; - runnable.run(function() { + runnable.run(function () { expect(runnable.isFailed(), 'to be false'); }); }); - it('should return `false` if test is pending', function() { - var runnable = new Runnable('foo', function() {}); + it('should return `false` if test is pending', function () { + var runnable = new Runnable('foo', function () {}); // runner sets the state - runnable.isPending = function() { + runnable.isPending = function () { return true; }; - runnable.run(function() { + runnable.run(function () { expect(runnable.isFailed(), 'to be false'); }); }); }); - describe('#resetTimeout()', function() { - it('should not time out if timeouts disabled after reset', function(done) { - var runnable = new Runnable('foo', function() {}); + describe('#resetTimeout()', function () { + it('should not time out if timeouts disabled after reset', function (done) { + var runnable = new Runnable('foo', function () {}); runnable.timeout(10); runnable.resetTimeout(); runnable.timeout(0); - setTimeout(function() { + setTimeout(function () { expect(runnable.timedOut, 'to be', false); done(); }, 20); }); }); - describe('static method', function() { - describe('toValueOrError', function() { - it('should return identity if parameter is truthy', function() { + describe('static method', function () { + describe('toValueOrError', function () { + it('should return identity if parameter is truthy', function () { expect(Runnable.toValueOrError('foo'), 'to be', 'foo'); }); - it('should return an Error if parameter is falsy', function() { + it('should return an Error if parameter is falsy', function () { expect(Runnable.toValueOrError(null), 'to be an', Error); }); }); }); - describe('interesting property', function() { - describe('id', function() { - it('should have a unique identifier', function() { + describe('interesting property', function () { + describe('id', function () { + it('should have a unique identifier', function () { expect(new Runnable('foo', () => {}), 'to have property', 'id'); }); - it('should have a permanent identifier', function() { + it('should have a permanent identifier', function () { const runnable = new Runnable('foo', () => {}); expect(runnable.id, 'to be', runnable.id); }); diff --git a/test/unit/runner.spec.js b/test/unit/runner.spec.js index 80542c7821..9c8a3016e6 100644 --- a/test/unit/runner.spec.js +++ b/test/unit/runner.spec.js @@ -6,11 +6,8 @@ const Mocha = require('../../lib/mocha'); const Pending = require('../../lib/pending'); const {Suite, Runner, Test, Hook, Runnable} = Mocha; const {noop} = Mocha.utils; -const { - FATAL, - MULTIPLE_DONE, - UNSUPPORTED -} = require('../../lib/errors').constants; +const {FATAL, MULTIPLE_DONE, UNSUPPORTED} = + require('../../lib/errors').constants; const errors = require('../../lib/errors'); const { @@ -28,13 +25,13 @@ const { } = Runner.constants; const {STATE_FAILED} = Mocha.Runnable.constants; -describe('Runner', function() { - afterEach(function() { +describe('Runner', function () { + afterEach(function () { sinon.restore(); }); - describe('constructor deprecation', function() { - it('should print a deprecation warning', function() { + describe('constructor deprecation', function () { + it('should print a deprecation warning', function () { sinon.stub(errors, 'deprecate'); const suite = new Suite('Suite', 'root'); new Runner(suite, false); /* eslint no-new: "off" */ @@ -42,17 +39,17 @@ describe('Runner', function() { }); }); - describe('instance method', function() { + describe('instance method', function () { let suite; let runner; - beforeEach(function() { + beforeEach(function () { suite = new Suite('Suite', 'root'); runner = new Runner(suite, {cleanReferencesAfterRun: true}); runner.checkLeaks = true; }); - describe('grep()', function() { - it('should update the runner.total with number of matched tests', function() { + describe('grep()', function () { + it('should update the runner.total with number of matched tests', function () { suite.addTest(new Test('im a test about lions', noop)); suite.addTest(new Test('im another test about lions', noop)); suite.addTest(new Test('im a test about bears', noop)); @@ -61,7 +58,7 @@ describe('Runner', function() { expect(newRunner.total, 'to be', 2); }); - it('should update the runner.total with number of matched tests when inverted', function() { + it('should update the runner.total with number of matched tests when inverted', function () { suite.addTest(new Test('im a test about lions', noop)); suite.addTest(new Test('im another test about lions', noop)); suite.addTest(new Test('im a test about bears', noop)); @@ -71,8 +68,8 @@ describe('Runner', function() { }); }); - describe('grepTotal()', function() { - it('should return the total number of matched tests', function() { + describe('grepTotal()', function () { + it('should return the total number of matched tests', function () { suite.addTest(new Test('im a test about lions', noop)); suite.addTest(new Test('im another test about lions', noop)); suite.addTest(new Test('im a test about bears', noop)); @@ -80,7 +77,7 @@ describe('Runner', function() { expect(runner.grepTotal(suite), 'to be', 2); }); - it('should return the total number of matched tests when inverted', function() { + it('should return the total number of matched tests when inverted', function () { suite.addTest(new Test('im a test about lions', noop)); suite.addTest(new Test('im another test about lions', noop)); suite.addTest(new Test('im a test about bears', noop)); @@ -88,8 +85,8 @@ describe('Runner', function() { expect(runner.grepTotal(suite), 'to be', 1); }); }); - describe('globalProps()', function() { - it('should include common non enumerable globals', function() { + describe('globalProps()', function () { + it('should include common non enumerable globals', function () { var props = runner.globalProps(); expect( props, @@ -104,25 +101,25 @@ describe('Runner', function() { }); }); - describe('globals()', function() { - it('should default to the known globals', function() { + describe('globals()', function () { + it('should default to the known globals', function () { expect(runner.globals().length, 'to be greater than', 16); }); - it('should white-list globals', function() { + it('should white-list globals', function () { runner.globals(['foo', 'bar']); expect(runner.globals(), 'to contain', 'foo', 'bar'); }); }); - describe('checkGlobals(test)', function() { - before(function() { + describe('checkGlobals(test)', function () { + before(function () { if (!Object.create) { this.skip(); } }); - it('should allow variables that match a wildcard', function(done) { + it('should allow variables that match a wildcard', function (done) { runner.globals(['foo*', 'giz*']); global.foo = 'baz'; global.gizmo = 'quux'; @@ -132,11 +129,11 @@ describe('Runner', function() { done(); }); - it('should emit "fail" when a new global is introduced', function(done) { + it('should emit "fail" when a new global is introduced', function (done) { var test = new Test('im a test', noop); runner.checkGlobals(); global.foo = 'bar'; - runner.on(EVENT_TEST_FAIL, function(_test, _err) { + runner.on(EVENT_TEST_FAIL, function (_test, _err) { expect(_test, 'to be', test); expect(_err, 'to have message', "global leak(s) detected: 'foo'"); delete global.foo; @@ -145,11 +142,11 @@ describe('Runner', function() { runner.checkGlobals(test); }); - it('should emit "fail" when a single new disallowed global is introduced after a single extra global is allowed', function(done) { + it('should emit "fail" when a single new disallowed global is introduced after a single extra global is allowed', function (done) { var doneCalled = false; runner.globals('good'); global.bad = 1; - runner.on(EVENT_TEST_FAIL, function() { + runner.on(EVENT_TEST_FAIL, function () { delete global.bad; done(); doneCalled = true; @@ -160,7 +157,7 @@ describe('Runner', function() { } }); - it('should not fail when a new common global is introduced', function() { + it('should not fail when a new common global is introduced', function () { if (process.browser) { this.skip(); return; @@ -193,12 +190,12 @@ describe('Runner', function() { delete global.XMLHttpRequest; }); - it('should pluralize the error message when several are introduced', function(done) { + it('should pluralize the error message when several are introduced', function (done) { var test = new Test('im a test', noop); runner.checkGlobals(); global.foo = 'bar'; global.bar = 'baz'; - runner.on(EVENT_TEST_FAIL, function(_test, _err) { + runner.on(EVENT_TEST_FAIL, function (_test, _err) { expect(_test, 'to be', test); expect( _err.message, @@ -212,7 +209,7 @@ describe('Runner', function() { runner.checkGlobals(test); }); - it('should respect per test whitelisted globals', function() { + it('should respect per test whitelisted globals', function () { var test = new Test('im a test about lions', noop); test.globals(['foo']); @@ -228,7 +225,7 @@ describe('Runner', function() { delete global.foo; }); - it('should respect per test whitelisted globals but still detect other leaks', function(done) { + it('should respect per test whitelisted globals but still detect other leaks', function (done) { var test = new Test('im a test about lions', noop); test.globals(['foo']); @@ -236,7 +233,7 @@ describe('Runner', function() { global.foo = 'whitelisted'; global.bar = 'detect-me'; - runner.on(EVENT_TEST_FAIL, function(_test, _err) { + runner.on(EVENT_TEST_FAIL, function (_test, _err) { expect(_test.title, 'to be', 'im a test about lions'); expect(_err, 'to have message', "global leak(s) detected: 'bar'"); delete global.foo; @@ -246,9 +243,9 @@ describe('Runner', function() { runner.checkGlobals(test); }); - it('should emit "fail" when a global beginning with "d" is introduced', function(done) { + it('should emit "fail" when a global beginning with "d" is introduced', function (done) { global.derp = 'bar'; - runner.on(EVENT_TEST_FAIL, function(_test, _err) { + runner.on(EVENT_TEST_FAIL, function (_test, _err) { expect(_test.title, 'to be', 'herp'); expect(_err, 'to have message', "global leak(s) detected: 'derp'"); delete global.derp; @@ -257,12 +254,12 @@ describe('Runner', function() { runner.checkGlobals(new Test('herp', noop)); }); }); - describe('hook()', function() { - it('should execute hooks after failed test if suite bail is true', function(done) { + describe('hook()', function () { + it('should execute hooks after failed test if suite bail is true', function (done) { runner.fail(new Test('failed test', noop), new Error()); suite.bail(true); - suite.afterEach(function() { - suite.afterAll(function() { + suite.afterEach(function () { + suite.afterAll(function () { done(); }); }); @@ -270,14 +267,14 @@ describe('Runner', function() { runner.hook('afterAll', noop); }); - it('should augment hook title with current test title', function(done) { + it('should augment hook title with current test title', function (done) { var expectedHookTitle; function assertHookTitle() { expect(hook.title, 'to be', expectedHookTitle); } var failHook = false; var hookError = new Error('failed hook'); - suite.beforeEach(function() { + suite.beforeEach(function () { assertHookTitle(); if (failHook) { throw hookError; @@ -295,13 +292,13 @@ describe('Runner', function() { runner.test = suite.tests[0]; expectedHookTitle = '"before each" hook for "should behave"'; - runner.hook('beforeEach', function(err) { + runner.hook('beforeEach', function (err) { if (err && err !== hookError) return done(err); runner.test = suite.tests[1]; failHook = true; expectedHookTitle = '"before each" hook for "should obey"'; - runner.hook('beforeEach', function(err) { + runner.hook('beforeEach', function (err) { if (err && err !== hookError) return done(err); return done(); }); @@ -309,8 +306,8 @@ describe('Runner', function() { }); }); - describe('fail()', function() { - it('should increment `Runner#failures`', function() { + describe('fail()', function () { + it('should increment `Runner#failures`', function () { expect(runner.failures, 'to be', 0); runner.fail(new Test('one', noop), {}); expect(runner.failures, 'to be', 1); @@ -318,16 +315,16 @@ describe('Runner', function() { expect(runner.failures, 'to be', 2); }); - it('should set `Test#state` to "failed"', function() { + it('should set `Test#state` to "failed"', function () { var test = new Test('some test', noop); runner.fail(test, 'some error'); expect(test.state, 'to be', STATE_FAILED); }); - it('should emit "fail"', function(done) { + it('should emit "fail"', function (done) { var test = new Test('some other test', noop); var err = {}; - runner.on(EVENT_TEST_FAIL, function(_test, _err) { + runner.on(EVENT_TEST_FAIL, function (_test, _err) { expect(_test, 'to be', test); expect(_err, 'to be an', Error); expect(_err, 'not to be', {}); @@ -336,10 +333,10 @@ describe('Runner', function() { runner.fail(test, err); }); - it('should emit a helpful message when failed with a string', function(done) { + it('should emit a helpful message when failed with a string', function (done) { var test = new Test('helpful test', noop); var err = 'string'; - runner.on(EVENT_TEST_FAIL, function(_test, _err) { + runner.on(EVENT_TEST_FAIL, function (_test, _err) { expect(_err, 'to be an', Error); expect( _err, @@ -351,10 +348,10 @@ describe('Runner', function() { runner.fail(test, err); }); - it('should emit a the error when failed with an Error instance', function(done) { + it('should emit a the error when failed with an Error instance', function (done) { var test = new Test('a test', noop); var err = new Error('an error message'); - runner.on(EVENT_TEST_FAIL, function(_test, _err) { + runner.on(EVENT_TEST_FAIL, function (_test, _err) { expect(_err, 'to be an', Error); expect(_err, 'to have message', 'an error message'); done(); @@ -362,10 +359,10 @@ describe('Runner', function() { runner.fail(test, err); }); - it('should emit the error when failed with an Error-like object', function(done) { + it('should emit the error when failed with an Error-like object', function (done) { var test = new Test('a test', noop); var err = {message: 'an error message'}; - runner.on(EVENT_TEST_FAIL, function(_test, _err) { + runner.on(EVENT_TEST_FAIL, function (_test, _err) { expect(_err, 'not to be an', Error); expect(_err.message, 'to be', 'an error message'); done(); @@ -373,10 +370,10 @@ describe('Runner', function() { runner.fail(test, err); }); - it('should emit a helpful message when failed with an Object', function(done) { + it('should emit a helpful message when failed with an Object', function (done) { var test = new Test('a test', noop); var err = {x: 1}; - runner.on(EVENT_TEST_FAIL, function(_test, _err) { + runner.on(EVENT_TEST_FAIL, function (_test, _err) { expect(_err, 'to be an', Error); expect( _err, @@ -388,10 +385,10 @@ describe('Runner', function() { runner.fail(test, err); }); - it('should emit a helpful message when failed with an Array', function(done) { + it('should emit a helpful message when failed with an Array', function (done) { var test = new Test('a test', noop); var err = [1, 2]; - runner.on(EVENT_TEST_FAIL, function(_test, _err) { + runner.on(EVENT_TEST_FAIL, function (_test, _err) { expect(_err, 'to be an', Error); expect( _err, @@ -403,7 +400,7 @@ describe('Runner', function() { runner.fail(test, err); }); - it('should recover if the error stack is not writable', function(done) { + it('should recover if the error stack is not writable', function (done) { if (!Object.create) { this.skip(); return; @@ -415,7 +412,7 @@ describe('Runner', function() { }); var test = new Test('a test', noop); - runner.on(EVENT_TEST_FAIL, function(_test, _err) { + runner.on(EVENT_TEST_FAIL, function (_test, _err) { expect(_err, 'to have message', 'not evil'); done(); }); @@ -423,7 +420,7 @@ describe('Runner', function() { runner.fail(test, err); }); - it('should return and not increment failures when test is pending', function() { + it('should return and not increment failures when test is pending', function () { var test = new Test('a test'); suite.addTest(test); test.pending = true; @@ -431,20 +428,20 @@ describe('Runner', function() { expect(runner.failures, 'to be', 0); }); - describe('when Runner has stopped', function() { - beforeEach(function() { + describe('when Runner has stopped', function () { + beforeEach(function () { runner.state = STATE_STOPPED; }); - describe('when test is not pending', function() { - describe('when error is the "multiple done" variety', function() { - it('should throw the "multiple done" error', function() { - var test = new Test('test', function() {}); + describe('when test is not pending', function () { + describe('when error is the "multiple done" variety', function () { + it('should throw the "multiple done" error', function () { + var test = new Test('test', function () {}); suite.addTest(test); var err = new Error(); err.code = MULTIPLE_DONE; expect( - function() { + function () { runner.fail(test, err); }, 'to throw', @@ -453,13 +450,13 @@ describe('Runner', function() { }); }); - describe('when error is not of the "multiple done" variety', function() { - it('should throw a "fatal" error', function() { - var test = new Test('test', function() {}); + describe('when error is not of the "multiple done" variety', function () { + it('should throw a "fatal" error', function () { + var test = new Test('test', function () {}); suite.addTest(test); var err = new Error(); expect( - function() { + function () { runner.fail(test, err); }, 'to throw', @@ -471,7 +468,7 @@ describe('Runner', function() { }); }); }); - it('should increment .failures', function() { + it('should increment .failures', function () { expect(runner.failures, 'to be', 0); var test1 = new Test('fail hook 1', noop); var test2 = new Test('fail hook 2', noop); @@ -483,11 +480,11 @@ describe('Runner', function() { expect(runner.failures, 'to be', 2); }); - it('should emit "fail"', function(done) { + it('should emit "fail"', function (done) { var hook = new Hook(); hook.parent = suite; var err = new Error('error'); - runner.on(EVENT_TEST_FAIL, function(_hook, _err) { + runner.on(EVENT_TEST_FAIL, function (_hook, _err) { expect(_hook, 'to be', hook); expect(_err, 'to be', err); done(); @@ -495,13 +492,13 @@ describe('Runner', function() { runner.fail(hook, err); }); - it('should not emit "end" if suite bail is not true', function(done) { + it('should not emit "end" if suite bail is not true', function (done) { var hook = new Hook(); hook.parent = suite; var err = new Error('error'); suite.bail(false); expect( - function() { + function () { runner.fail(hook, err); }, 'not to emit from', @@ -512,13 +509,13 @@ describe('Runner', function() { }); }); - describe('run()', function() { - it('should emit "retry" when a retryable test fails', function(done) { + describe('run()', function () { + it('should emit "retry" when a retryable test fails', function (done) { var retries = 2; var retryableFails = 0; var err = new Error('bear error'); - var test = new Test('im a test about bears', function() { + var test = new Test('im a test about bears', function () { if (retryableFails < retries) { throw err; } @@ -527,13 +524,13 @@ describe('Runner', function() { suite.retries(retries); suite.addTest(test); - runner.on(EVENT_TEST_RETRY, function(testClone, testErr) { + runner.on(EVENT_TEST_RETRY, function (testClone, testErr) { retryableFails += 1; expect(testClone.title, 'to be', test.title); expect(testErr, 'to be', err); }); - runner.run(function(failures) { + runner.run(function (failures) { expect(failures, 'to be', 0); expect(retryableFails, 'to be', retries); @@ -542,13 +539,13 @@ describe('Runner', function() { }); // karma-mocha is inexplicably doing this with a Hook - it('should not throw an exception if something emits EVENT_TEST_END with a non-Test object', function() { - expect(function() { + it('should not throw an exception if something emits EVENT_TEST_END with a non-Test object', function () { + expect(function () { runner.emit(EVENT_TEST_END, {}); }, 'not to throw'); }); - it('should clean references after a run', function() { + it('should clean references after a run', function () { runner = new Runner(suite, { delay: false, cleanReferencesAfterRun: true @@ -559,7 +556,7 @@ describe('Runner', function() { expect(cleanReferencesStub, 'was called once'); }); - it('should not clean references after a run when `cleanReferencesAfterRun` is `false`', function() { + it('should not clean references after a run when `cleanReferencesAfterRun` is `false`', function () { runner = new Runner(suite, { delay: false, cleanReferencesAfterRun: false @@ -570,10 +567,9 @@ describe('Runner', function() { expect(cleanReferencesStub, 'was not called'); }); - it('should not leak `Process.uncaughtException` listeners', function(done) { - var normalUncaughtExceptionListenerCount = process.listenerCount( - 'uncaughtException' - ); + it('should not leak `Process.uncaughtException` listeners', function (done) { + var normalUncaughtExceptionListenerCount = + process.listenerCount('uncaughtException'); runner.run(); runner.run(); @@ -586,7 +582,7 @@ describe('Runner', function() { done(); }); - describe('stack traces', function() { + describe('stack traces', function () { var stack = [ 'AssertionError: foo bar', 'at EventEmitter. (/usr/local/dev/test.js:16:12)', @@ -601,10 +597,10 @@ describe('Runner', function() { 'at processImmediate [as _immediateCallback] (timers.js:321:17)' ]; - before(function() { + before(function () { // Only for Node running on Windows if (process.platform === 'win32') { - var addDrive = function(str) { + var addDrive = function (str) { var drive = 'C:'; var pos = str.indexOf(path.posix.sep); return pos !== -1 @@ -612,32 +608,32 @@ describe('Runner', function() { : str; }; - var useWinPathSep = function(str) { + var useWinPathSep = function (str) { return str.split(path.posix.sep).join(path.win32.sep); }; // Fake Windows pathnames in stacktrace - stack = stack.map(function(line) { + stack = stack.map(function (line) { return useWinPathSep(addDrive(line)); }); } }); - describe('short', function() { - before(function() { + describe('short', function () { + before(function () { if (process.browser) { this.skip(); } }); - it('should prettify the stack-trace', function(done) { + it('should prettify the stack-trace', function (done) { var hook = new Hook(); hook.parent = suite; var err = new Error(); // Fake stack-trace err.stack = stack.join('\n'); - runner.on(EVENT_TEST_FAIL, function(_hook, _err) { + runner.on(EVENT_TEST_FAIL, function (_hook, _err) { expect(_err.stack, 'to be', stack.slice(0, 3).join('\n')); done(); }); @@ -645,8 +641,8 @@ describe('Runner', function() { }); }); - describe('long', function() { - it('should display the full stack-trace', function(done) { + describe('long', function () { + it('should display the full stack-trace', function (done) { var hook = new Hook(); hook.parent = suite; var err = new Error(); @@ -655,7 +651,7 @@ describe('Runner', function() { // Add --stack-trace option runner.fullStackTrace = true; - runner.on(EVENT_TEST_FAIL, function(_hook, _err) { + runner.on(EVENT_TEST_FAIL, function (_hook, _err) { expect(_err.stack, 'to be', stack.join('\n')); done(); }); @@ -663,8 +659,8 @@ describe('Runner', function() { }); }); - describe('ginormous', function() { - before(function() { + describe('ginormous', function () { + before(function () { if (process.browser) { this.skip(); } @@ -694,7 +690,7 @@ describe('Runner', function() { return data.join('\n'); } - it('should not hang if overlong error message is single line', function(done) { + it('should not hang if overlong error message is single line', function (done) { var hook = new Hook(); hook.parent = suite; var message = genOverlongSingleLineMessage(); @@ -702,7 +698,7 @@ describe('Runner', function() { // Fake stack-trace err.stack = [message].concat(stack).join('\n'); - runner.on(EVENT_TEST_FAIL, function(_hook, _err) { + runner.on(EVENT_TEST_FAIL, function (_hook, _err) { var filteredErrStack = _err.stack.split('\n').slice(1); expect( filteredErrStack.join('\n'), @@ -714,7 +710,7 @@ describe('Runner', function() { runner.fail(hook, err); }); - it('should not hang if overlong error message is multiple lines', function(done) { + it('should not hang if overlong error message is multiple lines', function (done) { var hook = new Hook(); hook.parent = suite; var message = genOverlongMultiLineMessage(); @@ -722,7 +718,7 @@ describe('Runner', function() { // Fake stack-trace err.stack = [message].concat(stack).join('\n'); - runner.on(EVENT_TEST_FAIL, function(_hook, _err) { + runner.on(EVENT_TEST_FAIL, function (_hook, _err) { var filteredErrStack = _err.stack.split('\n').slice(-3); expect( filteredErrStack.join('\n'), @@ -737,19 +733,16 @@ describe('Runner', function() { }); }); - describe('runAsync()', function() { - beforeEach(function() { - sinon - .stub(runner, 'run') - .callsArgWithAsync(0, 42) - .returnsThis(); + describe('runAsync()', function () { + beforeEach(function () { + sinon.stub(runner, 'run').callsArgWithAsync(0, 42).returnsThis(); }); - it('should return a Promise with a failure count', async function() { + it('should return a Promise with a failure count', async function () { return expect(runner.runAsync(), 'to be fulfilled with', 42); }); - it('should pass through options to Runner#run', async function() { + it('should pass through options to Runner#run', async function () { await runner.runAsync({foo: 'bar'}); expect(runner.run, 'to have a call satisfying', [ expect.it('to be a function'), @@ -758,14 +751,14 @@ describe('Runner', function() { }); }); - describe('dispose()', function() { - it('should remove all listeners from itself', function() { + describe('dispose()', function () { + it('should remove all listeners from itself', function () { runner.on('disposeShouldRemoveThis', noop); runner.dispose(); expect(runner.listenerCount('disposeShouldRemoveThis'), 'to be', 0); }); - it('should remove "error" listeners from a test', function() { + it('should remove "error" listeners from a test', function () { var fn = sinon.stub(); runner.test = new Test('test for dispose', fn); runner.runTest(noop); @@ -775,10 +768,9 @@ describe('Runner', function() { expect(runner.test.listenerCount('error'), 'to be', 0); }); - it('should remove "uncaughtException" listeners from the process', function() { - var normalUncaughtExceptionListenerCount = process.listenerCount( - 'uncaughtException' - ); + it('should remove "uncaughtException" listeners from the process', function () { + var normalUncaughtExceptionListenerCount = + process.listenerCount('uncaughtException'); runner.run(noop); // sanity check expect( @@ -795,18 +787,18 @@ describe('Runner', function() { }); }); - describe('runTest()', function() { - it('should return when no tests to run', function() { + describe('runTest()', function () { + it('should return when no tests to run', function () { runner.test = undefined; expect(runner.runTest(noop), 'to be undefined'); }); }); - describe('allowUncaught()', function() { - it('should allow unhandled errors to propagate through', function() { + describe('allowUncaught()', function () { + it('should allow unhandled errors to propagate through', function () { var newRunner = new Runner(suite); newRunner.allowUncaught = true; - newRunner.test = new Test('failing test', function() { + newRunner.test = new Test('failing test', function () { throw new Error('allow unhandled errors'); }); function fail() { @@ -815,8 +807,8 @@ describe('Runner', function() { expect(fail, 'to throw', 'allow unhandled errors'); }); - it('should not allow unhandled errors in sync hooks to propagate through', function(done) { - suite.beforeEach(function() { + it('should not allow unhandled errors in sync hooks to propagate through', function (done) { + suite.beforeEach(function () { throw new Error(); }); var runner = new Runner(suite); @@ -824,9 +816,9 @@ describe('Runner', function() { // We are monkey patching here with runner.once and a hook.run wrapper to effectively // capture thrown errors within the event loop phase where Runner.immediately executes - runner.once(EVENT_HOOK_BEGIN, function(hook) { + runner.once(EVENT_HOOK_BEGIN, function (hook) { var _run = hook.run; - hook.run = function(fn) { + hook.run = function (fn) { function throwError() { _run.call(hook, fn); } @@ -838,16 +830,16 @@ describe('Runner', function() { runner.hook('beforeEach', noop); }); - it('should allow unhandled errors in sync hooks to propagate through', function(done) { - suite.beforeEach(function() { + it('should allow unhandled errors in sync hooks to propagate through', function (done) { + suite.beforeEach(function () { throw new Error('allow unhandled errors in sync hooks'); }); var runner = new Runner(suite); runner.allowUncaught = true; - runner.once(EVENT_HOOK_BEGIN, function(hook) { + runner.once(EVENT_HOOK_BEGIN, function (hook) { var _run = hook.run; - hook.run = function(fn) { + hook.run = function (fn) { function throwError() { _run.call(hook, fn); } @@ -860,18 +852,18 @@ describe('Runner', function() { runner.hook('beforeEach', noop); }); - it('async - should allow unhandled errors in hooks to propagate through', function(done) { + it('async - should allow unhandled errors in hooks to propagate through', function (done) { // the `done` argument, although unused, it triggers the async path // see this.async in the Runnable constructor - suite.beforeEach(function(done) { + suite.beforeEach(function (done) { throw new Error('allow unhandled errors in async hooks'); }); var runner = new Runner(suite); runner.allowUncaught = true; - runner.once(EVENT_HOOK_BEGIN, function(hook) { + runner.once(EVENT_HOOK_BEGIN, function (hook) { var _run = hook.run; - hook.run = function(fn) { + hook.run = function (fn) { function throwError() { _run.call(hook, fn); } @@ -885,20 +877,20 @@ describe('Runner', function() { }); }); - describe('abort()', function() { - it('should set _abort property to true', function() { + describe('abort()', function () { + it('should set _abort property to true', function () { runner.abort(); expect(runner._abort, 'to be true'); }); - it('should return the Runner', function() { + it('should return the Runner', function () { expect(runner.abort(), 'to be', runner); }); }); - describe('_uncaught()', function() { - describe('when called with a non-Runner context', function() { - it('should throw', function() { + describe('_uncaught()', function () { + describe('when called with a non-Runner context', function () { + it('should throw', function () { expect(runner._uncaught.bind({}), 'to throw', { code: FATAL }); @@ -906,19 +898,19 @@ describe('Runner', function() { }); }); - describe('uncaught()', function() { - beforeEach(function() { + describe('uncaught()', function () { + beforeEach(function () { sinon.stub(runner, 'fail'); }); - describe('when allow-uncaught is set to true', function() { - it('should propagate error and throw', function() { + describe('when allow-uncaught is set to true', function () { + it('should propagate error and throw', function () { if (process.browser) this.skip(); var err = new Error('should rethrow err'); runner.allowUncaught = true; expect( - function() { + function () { runner.uncaught(err); }, 'to throw', @@ -927,14 +919,14 @@ describe('Runner', function() { }); }); - describe('when provided an object argument', function() { - describe('when argument is not an Error', function() { + describe('when provided an object argument', function () { + describe('when argument is not an Error', function () { var err; - beforeEach(function() { + beforeEach(function () { err = {whatever: 'yolo'}; }); - it('should fail with a transient Runnable and a new Error coerced from the object', function() { + it('should fail with a transient Runnable and a new Error coerced from the object', function () { runner.uncaught(err); expect(runner.fail, 'to have all calls satisfying', [ @@ -950,30 +942,30 @@ describe('Runner', function() { }); }); - describe('when argument is a Pending', function() { - it('should ignore argument and return', function() { + describe('when argument is a Pending', function () { + it('should ignore argument and return', function () { var err = new Pending(); expect(runner.uncaught(err), 'to be undefined'); }); }); - describe('when argument is an Error', function() { + describe('when argument is an Error', function () { var err; - beforeEach(function() { + beforeEach(function () { err = new Error('sorry dave'); }); - it('should add the "uncaught" property to the Error', function() { + it('should add the "uncaught" property to the Error', function () { runner.uncaught(err); expect(err, 'to have property', 'uncaught', true); }); - describe('when no Runnables are running', function() { - beforeEach(function() { + describe('when no Runnables are running', function () { + beforeEach(function () { delete runner.currentRunnable; }); - it('should fail with a transient Runnable and the error', function() { + it('should fail with a transient Runnable and the error', function () { runner.uncaught(err); expect(runner.fail, 'to have all calls satisfying', [ @@ -985,14 +977,14 @@ describe('Runner', function() { ]).and('was called once'); }); - describe('when Runner is RUNNING', function() { - beforeEach(function() { + describe('when Runner is RUNNING', function () { + beforeEach(function () { runner.state = STATE_RUNNING; }); - it('should not emit start/end events', function() { + it('should not emit start/end events', function () { expect( - function() { + function () { runner.uncaught(err); }, 'not to emit from', @@ -1002,14 +994,14 @@ describe('Runner', function() { }); }); - describe('when Runner is IDLE', function() { - beforeEach(function() { + describe('when Runner is IDLE', function () { + beforeEach(function () { runner.state = STATE_IDLE; }); - it('should emit start/end events for the benefit of reporters', function() { + it('should emit start/end events for the benefit of reporters', function () { expect( - function() { + function () { runner.uncaught(err); }, 'to emit from', @@ -1019,14 +1011,14 @@ describe('Runner', function() { }); }); - describe('when Runner is STOPPED', function() { - beforeEach(function() { + describe('when Runner is STOPPED', function () { + beforeEach(function () { runner.state = STATE_STOPPED; }); - it('should not emit start/end events, since this presumably would have already happened', function() { + it('should not emit start/end events, since this presumably would have already happened', function () { expect( - function() { + function () { try { runner.uncaught(err); } catch (ignored) {} @@ -1037,57 +1029,57 @@ describe('Runner', function() { ).and('not to emit from', runner, 'end'); }); - it('should throw', function() { - expect(function() { + it('should throw', function () { + expect(function () { runner.uncaught(err); }, 'to throw'); }); }); }); - describe('when a Runnable is running or has run', function() { + describe('when a Runnable is running or has run', function () { var runnable; - beforeEach(function() { + beforeEach(function () { runnable = new Runnable(); runnable.parent = runner.suite; sinon.stub(runnable, 'clearTimeout'); runner.currentRunnable = runnable; }); - it('should clear any pending timeouts', function() { + it('should clear any pending timeouts', function () { runnable.callback = sinon.fake(); runner.uncaught(err); expect(runnable.clearTimeout, 'was called times', 1); }); - describe('when current Runnable has already failed', function() { - beforeEach(function() { + describe('when current Runnable has already failed', function () { + beforeEach(function () { sinon.stub(runnable, 'isFailed').returns(true); }); - it('should not attempt to fail again', function() { + it('should not attempt to fail again', function () { runner.uncaught(err); expect(runner.fail, 'was not called'); }); }); - describe('when current Runnable has been marked pending', function() { - beforeEach(function() { + describe('when current Runnable has been marked pending', function () { + beforeEach(function () { sinon.stub(runnable, 'isPending').returns(true); }); - it('should attempt to fail', function() { + it('should attempt to fail', function () { runner.uncaught(err); expect(runner.fail, 'was called once'); }); }); - describe('when the current Runnable has already passed', function() { - beforeEach(function() { + describe('when the current Runnable has already passed', function () { + beforeEach(function () { sinon.stub(runnable, 'isPassed').returns(true); }); - it('should fail with the current Runnable and the error', function() { + it('should fail with the current Runnable and the error', function () { runner.uncaught(err); expect(runner.fail, 'to have all calls satisfying', [ @@ -1096,9 +1088,9 @@ describe('Runner', function() { ]).and('was called once'); }); - it('should abort the runner without emitting end event', function() { + it('should abort the runner without emitting end event', function () { expect( - function() { + function () { runner.uncaught(err); }, 'not to emit from', @@ -1109,16 +1101,16 @@ describe('Runner', function() { }); }); - describe('when the current Runnable is still running', function() { - describe('when the current Runnable is a Test', function() { - beforeEach(function() { + describe('when the current Runnable is still running', function () { + describe('when the current Runnable is a Test', function () { + beforeEach(function () { runnable = new Test('goomba', noop); runnable.parent = runner.suite; runner.currentRunnable = runnable; runnable.callback = sinon.fake(); }); - it('should run callback(err) to handle failing and hooks', function() { + it('should run callback(err) to handle failing and hooks', function () { runner.uncaught(err); expect(runner.fail, 'was not called'); @@ -1127,9 +1119,9 @@ describe('Runner', function() { ]).and('was called once'); }); - it('should not notify test has ended', function() { + it('should not notify test has ended', function () { expect( - function() { + function () { runner.uncaught(err); }, 'not to emit from', @@ -1138,9 +1130,9 @@ describe('Runner', function() { ); }); - it('should not notify run has ended', function() { + it('should not notify run has ended', function () { expect( - function() { + function () { runner.uncaught(err); }, 'not to emit from', @@ -1150,15 +1142,15 @@ describe('Runner', function() { }); }); - describe('when the current Runnable is a Hook', function() { - beforeEach(function() { + describe('when the current Runnable is a Hook', function () { + beforeEach(function () { runnable = new Hook(); runnable.parent = runner.suite; runner.currentRunnable = runnable; runnable.callback = sinon.fake(); }); - it('should run callback(err) to handle failing hook pattern', function() { + it('should run callback(err) to handle failing hook pattern', function () { runner.uncaught(err); expect(runner.fail, 'was not called'); @@ -1167,9 +1159,9 @@ describe('Runner', function() { ]).and('was called once'); }); - it('should not notify test has ended', function() { + it('should not notify test has ended', function () { expect( - function() { + function () { runner.uncaught(err); }, 'not to emit from', @@ -1178,9 +1170,9 @@ describe('Runner', function() { ); }); - it('should not notify run has ended', function() { + it('should not notify run has ended', function () { expect( - function() { + function () { runner.uncaught(err); }, 'not to emit from', @@ -1195,20 +1187,20 @@ describe('Runner', function() { }); }); - describe('linkPartialObjects()', function() { - it('should return the Runner', function() { + describe('linkPartialObjects()', function () { + it('should return the Runner', function () { expect(runner.linkPartialObjects(), 'to be', runner); }); }); - describe('isParallelMode()', function() { - it('should return false', function() { + describe('isParallelMode()', function () { + it('should return false', function () { expect(runner.isParallelMode(), 'to be false'); }); }); - describe('workerReporter()', function() { - it('should throw', function() { + describe('workerReporter()', function () { + it('should throw', function () { expect(() => runner.workerReporter(), 'to throw', {code: UNSUPPORTED}); }); }); diff --git a/test/unit/suite.spec.js b/test/unit/suite.spec.js index db2955113b..e7dc8e4f0f 100644 --- a/test/unit/suite.spec.js +++ b/test/unit/suite.spec.js @@ -10,16 +10,16 @@ function supportsFunctionNames() { return function foo() {}.name === 'foo'; } -describe('Suite', function() { - afterEach(function() { +describe('Suite', function () { + afterEach(function () { sinon.restore(); }); - describe('instance method', function() { + describe('instance method', function () { let suite; - describe('clone()', function() { - beforeEach(function() { + describe('clone()', function () { + beforeEach(function () { suite = new Suite('To be cloned', {}, true); suite._timeout = 3043; suite._slow = 101; @@ -32,7 +32,7 @@ describe('Suite', function() { suite._afterAll.push(5); }); - it('should clone the Suite, omitting children', function() { + it('should clone the Suite, omitting children', function () { expect(suite.clone(), 'to satisfy', { title: 'To be cloned', _timeout: 3043, @@ -49,20 +49,20 @@ describe('Suite', function() { }); }); - describe('reset()', function() { - beforeEach(function() { - suite = new Suite('Suite to be reset', function() {}); + describe('reset()', function () { + beforeEach(function () { + suite = new Suite('Suite to be reset', function () {}); }); - it('should reset the `delayed` state', function() { + it('should reset the `delayed` state', function () { suite.delayed = true; suite.reset(); expect(suite.delayed, 'to be', false); }); - it('should forward reset to suites and tests', function() { + it('should forward reset to suites and tests', function () { const childSuite = new Suite('child suite', suite.context); - const test = new Test('test', function() {}); + const test = new Test('test', function () {}); suite.addSuite(childSuite); suite.addTest(test); const testResetStub = sinon.stub(test, 'reset'); @@ -72,11 +72,11 @@ describe('Suite', function() { expect(suiteResetStub, 'was called once'); }); - it('should forward reset to all hooks', function() { - suite.beforeEach(function() {}); - suite.afterEach(function() {}); - suite.beforeAll(function() {}); - suite.afterAll(function() {}); + it('should forward reset to all hooks', function () { + suite.beforeEach(function () {}); + suite.afterEach(function () {}); + suite.beforeAll(function () {}); + suite.afterAll(function () {}); sinon.stub(suite.getHooks('beforeEach')[0], 'reset'); sinon.stub(suite.getHooks('afterEach')[0], 'reset'); sinon.stub(suite.getHooks('beforeAll')[0], 'reset'); @@ -91,79 +91,79 @@ describe('Suite', function() { }); }); - describe('timeout()', function() { - beforeEach(function() { + describe('timeout()', function () { + beforeEach(function () { suite = new Suite('A Suite'); }); - describe('when no argument is passed', function() { - it('should return the timeout value', function() { + describe('when no argument is passed', function () { + it('should return the timeout value', function () { expect(suite.timeout(), 'to be', 2000); }); }); - describe('when argument is passed', function() { - it('should return the Suite object', function() { + describe('when argument is passed', function () { + it('should return the Suite object', function () { const newSuite = suite.timeout(5000); expect(newSuite.timeout(), 'to be', 5000); }); }); }); - describe('slow()', function() { - beforeEach(function() { + describe('slow()', function () { + beforeEach(function () { suite = new Suite('A Suite'); }); - describe('when given a string', function() { - it('should parse it', function() { + describe('when given a string', function () { + it('should parse it', function () { suite.slow('5 seconds'); expect(suite.slow(), 'to be', 5000); }); }); - describe('when no argument is passed', function() { - it('should return the slow value', function() { + describe('when no argument is passed', function () { + it('should return the slow value', function () { expect(suite.slow(), 'to be', 75); }); }); - describe('when argument is passed', function() { - it('should return the Suite object', function() { + describe('when argument is passed', function () { + it('should return the Suite object', function () { const newSuite = suite.slow(5000); expect(newSuite.slow(), 'to be', 5000); }); }); }); - describe('bail()', function() { - beforeEach(function() { + describe('bail()', function () { + beforeEach(function () { suite = new Suite('A Suite'); suite._bail = true; }); - describe('when no argument is passed', function() { - it('should return the bail value', function() { + describe('when no argument is passed', function () { + it('should return the bail value', function () { expect(suite.bail(), 'to be', true); }); }); - describe('when argument is passed', function() { - it('should return the Suite object', function() { + describe('when argument is passed', function () { + it('should return the Suite object', function () { const newSuite = suite.bail(false); expect(newSuite.bail(), 'to be', false); }); }); }); - describe('beforeAll()', function() { - beforeEach(function() { + describe('beforeAll()', function () { + beforeEach(function () { suite = new Suite('A Suite'); }); - describe('wraps the passed in function in a Hook', function() { - it('adds it to _beforeAll', function() { - const fn = function() {}; + describe('wraps the passed in function in a Hook', function () { + it('adds it to _beforeAll', function () { + const fn = function () {}; suite.beforeAll(fn); expect(suite._beforeAll, 'to have length', 1); @@ -172,8 +172,8 @@ describe('Suite', function() { expect(beforeAllItem.fn, 'to be', fn); }); - it('appends title to hook', function() { - const fn = function() {}; + it('appends title to hook', function () { + const fn = function () {}; suite.beforeAll('test', fn); expect(suite._beforeAll, 'to have length', 1); @@ -182,7 +182,7 @@ describe('Suite', function() { expect(beforeAllItem.fn, 'to be', fn); }); - it('uses function name if available', function() { + it('uses function name if available', function () { if (!supportsFunctionNames()) { this.skip(); return; @@ -196,14 +196,14 @@ describe('Suite', function() { }); }); - describe('afterAll()', function() { - beforeEach(function() { + describe('afterAll()', function () { + beforeEach(function () { suite = new Suite('A Suite'); }); - describe('wraps the passed in function in a Hook', function() { - it('adds it to _afterAll', function() { - const fn = function() {}; + describe('wraps the passed in function in a Hook', function () { + it('adds it to _afterAll', function () { + const fn = function () {}; suite.afterAll(fn); expect(suite._afterAll, 'to have length', 1); @@ -211,8 +211,8 @@ describe('Suite', function() { expect(afterAllItem.title, 'to match', /^"after all" hook/); expect(afterAllItem.fn, 'to be', fn); }); - it('appends title to hook', function() { - const fn = function() {}; + it('appends title to hook', function () { + const fn = function () {}; suite.afterAll('test', fn); expect(suite._afterAll, 'to have length', 1); @@ -221,7 +221,7 @@ describe('Suite', function() { expect(beforeAllItem.fn, 'to be', fn); }); - it('uses function name if available', function() { + it('uses function name if available', function () { if (!supportsFunctionNames()) { this.skip(); return; @@ -235,16 +235,16 @@ describe('Suite', function() { }); }); - describe('beforeEach()', function() { + describe('beforeEach()', function () { let suite; - beforeEach(function() { + beforeEach(function () { suite = new Suite('A Suite'); }); - describe('wraps the passed in function in a Hook', function() { - it('adds it to _beforeEach', function() { - const fn = function() {}; + describe('wraps the passed in function in a Hook', function () { + it('adds it to _beforeEach', function () { + const fn = function () {}; suite.beforeEach(fn); expect(suite._beforeEach, 'to have length', 1); @@ -253,8 +253,8 @@ describe('Suite', function() { expect(beforeEachItem.fn, 'to be', fn); }); - it('appends title to hook', function() { - const fn = function() {}; + it('appends title to hook', function () { + const fn = function () {}; suite.beforeEach('test', fn); expect(suite._beforeEach, 'to have length', 1); @@ -263,7 +263,7 @@ describe('Suite', function() { expect(beforeAllItem.fn, 'to be', fn); }); - it('uses function name if available', function() { + it('uses function name if available', function () { if (!supportsFunctionNames()) { this.skip(); return; @@ -276,26 +276,26 @@ describe('Suite', function() { }); }); - describe('when the suite is pending', function() { - beforeEach(function() { + describe('when the suite is pending', function () { + beforeEach(function () { suite.pending = true; }); - it('should not create a hook', function() { - suite.beforeEach(function() {}); + it('should not create a hook', function () { + suite.beforeEach(function () {}); expect(suite._beforeEach, 'to be empty'); }); }); }); - describe('afterEach()', function() { - beforeEach(function() { + describe('afterEach()', function () { + beforeEach(function () { suite = new Suite('A Suite'); }); - describe('wraps the passed in function in a Hook', function() { - it('adds it to _afterEach', function() { - const fn = function() {}; + describe('wraps the passed in function in a Hook', function () { + it('adds it to _afterEach', function () { + const fn = function () {}; suite.afterEach(fn); expect(suite._afterEach, 'to have length', 1); @@ -304,8 +304,8 @@ describe('Suite', function() { expect(afterEachItem.fn, 'to be', fn); }); - it('appends title to hook', function() { - const fn = function() {}; + it('appends title to hook', function () { + const fn = function () {}; suite.afterEach('test', fn); expect(suite._afterEach, 'to have length', 1); @@ -314,7 +314,7 @@ describe('Suite', function() { expect(beforeAllItem.fn, 'to be', fn); }); - it('uses function name if available', function() { + it('uses function name if available', function () { if (!supportsFunctionNames()) { this.skip(); return; @@ -328,23 +328,23 @@ describe('Suite', function() { }); }); - describe('create()', function() { + describe('create()', function () { let first; let second; - before(function() { + before(function () { first = new Suite('Root suite', {}, true); second = new Suite('RottenRoot suite', {}, true); first.addSuite(second); }); - it('does not create a second root suite', function() { + it('does not create a second root suite', function () { expect(second.parent, 'to be', first); expect(first.root, 'to be', true); expect(second.root, 'to be', false); }); - it('does not denote the root suite by being titleless', function() { + it('does not denote the root suite by being titleless', function () { const emptyTitleSuite = Suite.create(second, ''); expect(emptyTitleSuite.parent, 'to be', second); expect(emptyTitleSuite.root, 'to be', false); @@ -352,11 +352,11 @@ describe('Suite', function() { }); }); - describe('addSuite()', function() { + describe('addSuite()', function () { let first; let second; - beforeEach(function() { + beforeEach(function () { first = new Suite('First suite'); first.timeout(4002); first.slow(200); @@ -364,65 +364,65 @@ describe('Suite', function() { first.addSuite(second); }); - it('sets the parent on the added Suite', function() { + it('sets the parent on the added Suite', function () { expect(second.parent, 'to be', first); }); - it('copies the timeout value', function() { + it('copies the timeout value', function () { expect(second.timeout(), 'to be', 4002); }); - it('copies the slow value', function() { + it('copies the slow value', function () { expect(second.slow(), 'to be', 200); }); - it('adds the suite to the suites collection', function() { + it('adds the suite to the suites collection', function () { expect(first.suites, 'to have length', 1); expect(first.suites[0], 'to be', second); }); - it('treats suite as pending if its parent is pending', function() { + it('treats suite as pending if its parent is pending', function () { first.pending = true; expect(second.isPending(), 'to be', true); }); }); - describe('addTest()', function() { + describe('addTest()', function () { let test; - beforeEach(function() { + beforeEach(function () { suite = new Suite('A Suite', new Context()); suite.timeout(4002); test = new Test('test'); suite.addTest(test); }); - it('sets the parent on the added test', function() { + it('sets the parent on the added test', function () { expect(test.parent, 'to be', suite); }); - it('copies the timeout value', function() { + it('copies the timeout value', function () { expect(test.timeout(), 'to be', 4002); }); - it('adds the test to the tests collection', function() { + it('adds the test to the tests collection', function () { expect(suite.tests, 'to satisfy', [test]).and('to have length', 1); }); }); - describe('fullTitle()', function() { - beforeEach(function() { + describe('fullTitle()', function () { + beforeEach(function () { suite = new Suite('A Suite'); }); - describe('when there is no parent', function() { - it('returns the suite title', function() { + describe('when there is no parent', function () { + it('returns the suite title', function () { expect(suite.fullTitle(), 'to be', 'A Suite'); }); }); - describe('when there is a parent', function() { - it("returns the combination of parent's and suite's title", function() { + describe('when there is a parent', function () { + it("returns the combination of parent's and suite's title", function () { const parentSuite = new Suite('I am a parent'); parentSuite.addSuite(suite); expect(suite.fullTitle(), 'to be', 'I am a parent A Suite'); @@ -430,28 +430,28 @@ describe('Suite', function() { }); }); - describe('titlePath()', function() { - beforeEach(function() { + describe('titlePath()', function () { + beforeEach(function () { suite = new Suite('A Suite'); }); - describe('when there is no parent', function() { - it('returns the suite title', function() { + describe('when there is no parent', function () { + it('returns the suite title', function () { expect(suite.titlePath(), 'to equal', ['A Suite']); }); }); - describe('when there is a parent', function() { - describe('the parent is the root suite', function() { - it('returns the suite title', function() { + describe('when there is a parent', function () { + describe('the parent is the root suite', function () { + it('returns the suite title', function () { const rootSuite = new Suite('', {}, true); rootSuite.addSuite(suite); expect(suite.titlePath(), 'to equal', ['A Suite']); }); }); - describe('the parent is not the root suite', function() { - it("returns the concatenation of parent's and suite's title", function() { + describe('the parent is not the root suite', function () { + it("returns the concatenation of parent's and suite's title", function () { const parentSuite = new Suite('I am a parent'); parentSuite.addSuite(suite); expect(suite.titlePath(), 'to equal', ['I am a parent', 'A Suite']); @@ -460,19 +460,19 @@ describe('Suite', function() { }); }); - describe('total()', function() { - beforeEach(function() { + describe('total()', function () { + beforeEach(function () { suite = new Suite('A Suite'); }); - describe('when there are no nested suites or tests', function() { - it('should return 0', function() { + describe('when there are no nested suites or tests', function () { + it('should return 0', function () { expect(suite.total(), 'to be', 0); }); }); - describe('when there are several tests in the suite', function() { - it('should return the number', function() { + describe('when there are several tests in the suite', function () { + it('should return the number', function () { suite.addTest(new Test('a child test')); suite.addTest(new Test('another child test')); expect(suite.total(), 'to be', 2); @@ -480,13 +480,13 @@ describe('Suite', function() { }); }); - describe('eachTest(fn)', function() { - beforeEach(function() { + describe('eachTest(fn)', function () { + beforeEach(function () { suite = new Suite('A Suite'); }); - describe('when there are no nested suites or tests', function() { - it('should return 0', function() { + describe('when there are no nested suites or tests', function () { + it('should return 0', function () { let n = 0; function fn() { n++; @@ -496,8 +496,8 @@ describe('Suite', function() { }); }); - describe('when there are several tests in the suite', function() { - it('should return the number', function() { + describe('when there are several tests in the suite', function () { + it('should return the number', function () { suite.addTest(new Test('a child test')); suite.addTest(new Test('another child test')); @@ -510,8 +510,8 @@ describe('Suite', function() { }); }); - describe('when there are several levels of nested suites', function() { - it('should return the number', function() { + describe('when there are several levels of nested suites', function () { + it('should return the number', function () { suite.addTest(new Test('a child test')); const childSuite = new Suite('a child suite'); childSuite.addTest(new Test('a test in a child suite')); @@ -527,39 +527,39 @@ describe('Suite', function() { }); }); - describe('constructor', function() { - beforeEach(function() { + describe('constructor', function () { + beforeEach(function () { sinon.stub(errors, 'deprecate'); }); /* eslint no-new: off */ - it("should throw an error if the title isn't a string", function() { - expect(function() { + it("should throw an error if the title isn't a string", function () { + expect(function () { new Suite(undefined, 'root'); }, 'to throw'); - expect(function() { - new Suite(function() {}, 'root'); + expect(function () { + new Suite(function () {}, 'root'); }, 'to throw'); }); - it('should not throw if the title is a string', function() { - expect(function() { + it('should not throw if the title is a string', function () { + expect(function () { new Suite('Bdd suite', 'root'); }, 'not to throw'); }); }); - describe('timeout()', function() { - it('should convert a string to milliseconds', function() { + describe('timeout()', function () { + it('should convert a string to milliseconds', function () { const suite = new Suite('some suite'); suite.timeout('100'); expect(suite.timeout(), 'to be', 100); }); }); - describe('hasOnly()', function() { - it('should return true if a test has `only`', function() { + describe('hasOnly()', function () { + it('should return true if a test has `only`', function () { const suite = new Suite('foo'); const test = new Test('bar'); @@ -568,7 +568,7 @@ describe('Suite', function() { expect(suite.hasOnly(), 'to be', true); }); - it('should return true if a suite has `only`', function() { + it('should return true if a suite has `only`', function () { const suite = new Suite('foo'); const nested = new Suite('bar'); @@ -577,7 +577,7 @@ describe('Suite', function() { expect(suite.hasOnly(), 'to be', true); }); - it('should return true if nested suite has `only`', function() { + it('should return true if nested suite has `only`', function () { const suite = new Suite('foo'); const nested = new Suite('bar'); const test = new Test('baz'); @@ -589,7 +589,7 @@ describe('Suite', function() { expect(suite.hasOnly(), 'to be', true); }); - it('should return false if no suite or test is marked `only`', function() { + it('should return false if no suite or test is marked `only`', function () { const suite = new Suite('foo'); const nested = new Suite('bar'); const test = new Test('baz'); @@ -601,8 +601,8 @@ describe('Suite', function() { }); }); - describe('filterOnly()', function() { - it('should filter out all other tests and suites if a test has `only`', function() { + describe('filterOnly()', function () { + it('should filter out all other tests and suites if a test has `only`', function () { const suite = new Suite('a'); const nested = new Suite('b'); const test = new Test('c'); @@ -622,7 +622,7 @@ describe('Suite', function() { }); }); - it('should filter out all other tests and suites if a suite has `only`', function() { + it('should filter out all other tests and suites if a suite has `only`', function () { const suite = new Suite('a'); const nested1 = new Suite('b'); const nested2 = new Suite('c'); @@ -647,8 +647,8 @@ describe('Suite', function() { }); }); - describe('markOnly()', function() { - it('should call appendOnlySuite on parent', function() { + describe('markOnly()', function () { + it('should call appendOnlySuite on parent', function () { const suite = new Suite('foo'); const spy = sinon.spy(); suite.parent = { @@ -664,21 +664,21 @@ describe('Suite', function() { }); }); -describe('Test', function() { - describe('initialization', function() { - it("should throw an error if the title isn't a string", function() { - expect(function() { - new Test(function() {}); +describe('Test', function () { + describe('initialization', function () { + it("should throw an error if the title isn't a string", function () { + expect(function () { + new Test(function () {}); }, 'to throw'); expect(() => { - new Test(undefined, function() {}); + new Test(undefined, function () {}); }, 'to throw'); }); - it('should not throw if the title is a string', function() { - expect(function() { - new Test('test-case', function() {}); + it('should not throw if the title is a string', function () { + expect(function () { + new Test('test-case', function () {}); }, 'not to throw'); }); }); diff --git a/test/unit/test.spec.js b/test/unit/test.spec.js index 9d156d5a8f..8bd394cc73 100644 --- a/test/unit/test.spec.js +++ b/test/unit/test.spec.js @@ -5,14 +5,14 @@ var mocha = require('../../lib/mocha'); var Test = mocha.Test; var Runnable = mocha.Runnable; -describe('Test', function() { - afterEach(function() { +describe('Test', function () { + afterEach(function () { sinon.restore(); }); - describe('.clone()', function() { - beforeEach(function() { - this._test = new Test('To be cloned', function() {}); + describe('.clone()', function () { + beforeEach(function () { + this._test = new Test('To be cloned', function () {}); this._test._timeout = 3043; this._test._slow = 101; this._test._retries = 3; @@ -22,80 +22,80 @@ describe('Test', function() { this._test.file = 'bar'; }); - it('should copy the title', function() { + it('should copy the title', function () { expect(this._test.clone().title, 'to be', 'To be cloned'); }); - it('should copy the timeout value', function() { + it('should copy the timeout value', function () { expect(this._test.clone().timeout(), 'to be', 3043); }); - it('should copy the slow value', function() { + it('should copy the slow value', function () { expect(this._test.clone().slow(), 'to be', 101); }); - it('should copy the retries value', function() { + it('should copy the retries value', function () { expect(this._test.clone().retries(), 'to be', 3); }); - it('should copy the currentRetry value', function() { + it('should copy the currentRetry value', function () { expect(this._test.clone().currentRetry(), 'to be', 1); }); - it('should add/keep the retriedTest value', function() { + it('should add/keep the retriedTest value', function () { var clone1 = this._test.clone(); expect(clone1.retriedTest(), 'to be', this._test); expect(clone1.clone().retriedTest(), 'to be', this._test); }); - it('should copy the globals value', function() { + it('should copy the globals value', function () { expect(this._test.clone().globals(), 'not to be empty'); }); - it('should copy the parent value', function() { + it('should copy the parent value', function () { expect(this._test.clone().parent, 'to be', 'foo'); }); - it('should copy the file value', function() { + it('should copy the file value', function () { expect(this._test.clone().file, 'to be', 'bar'); }); }); - describe('.reset()', function() { - beforeEach(function() { - this._test = new Test('Test to be reset', function() {}); + describe('.reset()', function () { + beforeEach(function () { + this._test = new Test('Test to be reset', function () {}); }); - it('should reset the run state', function() { + it('should reset the run state', function () { this._test.pending = true; this._test.reset(); expect(this._test.pending, 'to be', false); }); - it('should call Runnable.reset', function() { + it('should call Runnable.reset', function () { var runnableResetStub = sinon.stub(Runnable.prototype, 'reset'); this._test.reset(); expect(runnableResetStub, 'was called once'); }); }); - describe('.isPending()', function() { - beforeEach(function() { - this._test = new Test('Is it skipped', function() {}); + describe('.isPending()', function () { + beforeEach(function () { + this._test = new Test('Is it skipped', function () {}); }); - it('should not be pending by default', function() { + it('should not be pending by default', function () { expect(this._test.isPending(), 'not to be', true); }); - it('should be pending when marked as such', function() { + it('should be pending when marked as such', function () { this._test.pending = true; expect(this._test.isPending(), 'to be', true); }); - it('should be pending when its parent is pending', function() { + it('should be pending when its parent is pending', function () { this._test.parent = { - isPending: function() { + isPending: function () { return true; } }; @@ -103,12 +103,12 @@ describe('Test', function() { }); }); - describe('.markOnly()', function() { - afterEach(function() { + describe('.markOnly()', function () { + afterEach(function () { sinon.restore(); }); - it('should call appendOnlyTest on parent', function() { + it('should call appendOnlyTest on parent', function () { var test = new Test('foo'); var spy = sinon.spy(); test.parent = { diff --git a/test/unit/throw.spec.js b/test/unit/throw.spec.js index 1e02a3a085..ccb7ef6c11 100644 --- a/test/unit/throw.spec.js +++ b/test/unit/throw.spec.js @@ -10,12 +10,12 @@ var Runner = Mocha.Runner; var EVENT_RUN_END = Runner.constants.EVENT_RUN_END; var STATE_FAILED = Runnable.constants.STATE_FAILED; -describe('a test that throws', function() { +describe('a test that throws', function () { var suite; var runner; var uncaughtHandlers; - beforeEach(function() { + beforeEach(function () { suite = new Suite('Suite', 'root'); runner = new Runner(suite); @@ -24,21 +24,21 @@ describe('a test that throws', function() { process.removeAllListeners('uncaughtException'); }); - afterEach(function() { + afterEach(function () { process.removeAllListeners('uncaughtException'); - uncaughtHandlers.forEach(function(listener) { + uncaughtHandlers.forEach(function (listener) { process.on('uncaughtException', listener); }); }); - describe('non-extensible', function() { - it('should not pass if throwing sync and test is sync', function(done) { - var test = new Test('im sync and throw string sync', function() { + describe('non-extensible', function () { + it('should not pass if throwing sync and test is sync', function (done) { + var test = new Test('im sync and throw string sync', function () { throw 'non-extensible'; }); suite.addTest(test); runner = new Runner(suite); - runner.on(EVENT_RUN_END, function() { + runner.on(EVENT_RUN_END, function () { expect(runner.failures, 'to be', 1); expect(test.state, 'to be', STATE_FAILED); done(); @@ -46,13 +46,13 @@ describe('a test that throws', function() { runner.run(); }); - it('should not pass if throwing sync and test is async', function(done) { - var test = new Test('im async and throw string sync', function(done2) { + it('should not pass if throwing sync and test is async', function (done) { + var test = new Test('im async and throw string sync', function (done2) { throw 'non-extensible'; }); suite.addTest(test); runner = new Runner(suite); - runner.on(EVENT_RUN_END, function() { + runner.on(EVENT_RUN_END, function () { expect(runner.failures, 'to be', 1); expect(test.state, 'to be', STATE_FAILED); done(); @@ -60,15 +60,15 @@ describe('a test that throws', function() { runner.run(); }); - it('should not pass if throwing async and test is async', function(done) { - var test = new Test('im async and throw string async', function(done2) { - process.nextTick(function() { + it('should not pass if throwing async and test is async', function (done) { + var test = new Test('im async and throw string async', function (done2) { + process.nextTick(function () { throw 'non-extensible'; }); }); suite.addTest(test); runner = new Runner(suite); - runner.on(EVENT_RUN_END, function() { + runner.on(EVENT_RUN_END, function () { expect(runner.failures, 'to be', 1); expect(test.state, 'to be', STATE_FAILED); done(); @@ -77,14 +77,14 @@ describe('a test that throws', function() { }); }); - describe('undefined', function() { - it('should not pass if throwing sync and test is sync', function(done) { - var test = new Test('im sync and throw undefined sync', function() { + describe('undefined', function () { + it('should not pass if throwing sync and test is sync', function (done) { + var test = new Test('im sync and throw undefined sync', function () { throw undefined; }); suite.addTest(test); runner = new Runner(suite); - runner.on(EVENT_RUN_END, function() { + runner.on(EVENT_RUN_END, function () { expect(runner.failures, 'to be', 1); expect(test.state, 'to be', STATE_FAILED); done(); @@ -92,13 +92,15 @@ describe('a test that throws', function() { runner.run(); }); - it('should not pass if throwing sync and test is async', function(done) { - var test = new Test('im async and throw undefined sync', function(done2) { + it('should not pass if throwing sync and test is async', function (done) { + var test = new Test('im async and throw undefined sync', function ( + done2 + ) { throw undefined; }); suite.addTest(test); runner = new Runner(suite); - runner.on(EVENT_RUN_END, function() { + runner.on(EVENT_RUN_END, function () { expect(runner.failures, 'to be', 1); expect(test.state, 'to be', STATE_FAILED); done(); @@ -106,17 +108,17 @@ describe('a test that throws', function() { runner.run(); }); - it('should not pass if throwing async and test is async', function(done) { - var test = new Test('im async and throw undefined async', function( + it('should not pass if throwing async and test is async', function (done) { + var test = new Test('im async and throw undefined async', function ( done2 ) { - process.nextTick(function() { + process.nextTick(function () { throw undefined; }); }); suite.addTest(test); runner = new Runner(suite); - runner.on(EVENT_RUN_END, function() { + runner.on(EVENT_RUN_END, function () { expect(runner.failures, 'to be', 1); expect(test.state, 'to be', STATE_FAILED); done(); @@ -125,14 +127,14 @@ describe('a test that throws', function() { }); }); - describe('null', function() { - it('should not pass if throwing sync and test is sync', function(done) { - var test = new Test('im sync and throw null sync', function() { + describe('null', function () { + it('should not pass if throwing sync and test is sync', function (done) { + var test = new Test('im sync and throw null sync', function () { throw null; }); suite.addTest(test); runner = new Runner(suite); - runner.on(EVENT_RUN_END, function() { + runner.on(EVENT_RUN_END, function () { expect(runner.failures, 'to be', 1); expect(test.state, 'to be', STATE_FAILED); done(); @@ -140,13 +142,13 @@ describe('a test that throws', function() { runner.run(); }); - it('should not pass if throwing sync and test is async', function(done) { - var test = new Test('im async and throw null sync', function(done2) { + it('should not pass if throwing sync and test is async', function (done) { + var test = new Test('im async and throw null sync', function (done2) { throw null; }); suite.addTest(test); runner = new Runner(suite); - runner.on(EVENT_RUN_END, function() { + runner.on(EVENT_RUN_END, function () { expect(runner.failures, 'to be', 1); expect(test.state, 'to be', STATE_FAILED); done(); @@ -154,15 +156,15 @@ describe('a test that throws', function() { runner.run(); }); - it('should not pass if throwing async and test is async', function(done) { - var test = new Test('im async and throw null async', function(done2) { - process.nextTick(function() { + it('should not pass if throwing async and test is async', function (done) { + var test = new Test('im async and throw null async', function (done2) { + process.nextTick(function () { throw null; }); }); suite.addTest(test); runner = new Runner(suite); - runner.on(EVENT_RUN_END, function() { + runner.on(EVENT_RUN_END, function () { expect(runner.failures, 'to be', 1); expect(test.state, 'to be', STATE_FAILED); done(); diff --git a/test/unit/timeout.spec.js b/test/unit/timeout.spec.js index 5cf3dce3b7..ed65156341 100644 --- a/test/unit/timeout.spec.js +++ b/test/unit/timeout.spec.js @@ -1,55 +1,55 @@ 'use strict'; -describe('timeouts', function() { - beforeEach(function(done) { +describe('timeouts', function () { + beforeEach(function (done) { // uncomment // setTimeout(done, 3000); done(); }); - it('should error on timeout', function(done) { + it('should error on timeout', function (done) { // uncomment // setTimeout(done, 3000); done(); }); - it('should allow overriding per-test', function(done) { + it('should allow overriding per-test', function (done) { this.timeout(1500); - setTimeout(function() { + setTimeout(function () { done(); }, 50); }); - describe('disabling', function() { - it('should work with timeout(0)', function(done) { + describe('disabling', function () { + it('should work with timeout(0)', function (done) { this.timeout(0); setTimeout(done, 1); }); - describe('using beforeEach', function() { - beforeEach(function() { + describe('using beforeEach', function () { + beforeEach(function () { this.timeout(0); }); - it('should work with timeout(0)', function(done) { + it('should work with timeout(0)', function (done) { setTimeout(done, 1); }); }); - describe('using before', function() { - before(function() { + describe('using before', function () { + before(function () { this.timeout(0); }); - it('should work with timeout(0)', function(done) { + it('should work with timeout(0)', function (done) { setTimeout(done, 1); }); }); - describe('using timeout(0)', function() { + describe('using timeout(0)', function () { this.timeout(4); - it('should suppress timeout(4)', function(done) { + it('should suppress timeout(4)', function (done) { this.slow(100); // The test is in the before() call. this.timeout(0); @@ -57,15 +57,15 @@ describe('timeouts', function() { }); }); - describe('suite-level', function() { + describe('suite-level', function () { this.timeout(0); - it('should work with timeout(0)', function(done) { + it('should work with timeout(0)', function (done) { setTimeout(done, 1); }); - describe('nested suite', function() { - it('should work with timeout(0)', function(done) { + describe('nested suite', function () { + it('should work with timeout(0)', function (done) { setTimeout(done, 1); }); }); diff --git a/test/unit/utils.spec.js b/test/unit/utils.spec.js index 505b0f14f1..336bb1698e 100644 --- a/test/unit/utils.spec.js +++ b/test/unit/utils.spec.js @@ -4,13 +4,13 @@ var utils = require('../../lib/utils'); var sinon = require('sinon'); -describe('lib/utils', function() { - afterEach(function() { +describe('lib/utils', function () { + afterEach(function () { sinon.restore(); }); - describe('clean()', function() { - it('should remove the wrapping function declaration', function() { + describe('clean()', function () { + it('should remove the wrapping function declaration', function () { expect( utils.clean('function (one, two, three) {\n//code\n}'), 'to be', @@ -18,7 +18,7 @@ describe('lib/utils', function() { ); }); - it('should handle newlines in the function declaration', function() { + it('should handle newlines in the function declaration', function () { expect( utils.clean('function (one, two, three)\n {\n//code\n}'), 'to be', @@ -26,7 +26,7 @@ describe('lib/utils', function() { ); }); - it('should remove space character indentation from the function body', function() { + it('should remove space character indentation from the function body', function () { expect( utils.clean(' //line1\n //line2'), 'to be', @@ -34,7 +34,7 @@ describe('lib/utils', function() { ); }); - it('should remove tab character indentation from the function body', function() { + it('should remove tab character indentation from the function body', function () { expect( utils.clean('\t//line1\n\t\t//line2'), 'to be', @@ -42,11 +42,11 @@ describe('lib/utils', function() { ); }); - it('should handle functions with tabs in their declarations', function() { + it('should handle functions with tabs in their declarations', function () { expect(utils.clean('function\t(\t)\t{\n//code\n}'), 'to be', '//code'); }); - it('should handle named functions without space after name', function() { + it('should handle named functions without space after name', function () { expect( utils.clean('function withName() {\n//code\n}'), 'to be', @@ -54,7 +54,7 @@ describe('lib/utils', function() { ); }); - it('should handle named functions with space after name', function() { + it('should handle named functions with space after name', function () { expect( utils.clean('function withName () {\n//code\n}'), 'to be', @@ -62,11 +62,11 @@ describe('lib/utils', function() { ); }); - it('should handle functions with no space between the end and the closing brace', function() { + it('should handle functions with no space between the end and the closing brace', function () { expect(utils.clean('function() {/*code*/}'), 'to be', '/*code*/'); }); - it('should handle functions with parentheses in the same line', function() { + it('should handle functions with parentheses in the same line', function () { expect( utils.clean('function() { if (true) { /* code */ } }'), 'to be', @@ -74,16 +74,16 @@ describe('lib/utils', function() { ); }); - it('should handle empty functions', function() { + it('should handle empty functions', function () { expect(utils.clean('function() {}'), 'to be', ''); }); - it('should format a single line test function', function() { + it('should format a single line test function', function () { var fn = ['function () {', ' var a = 1;', '}'].join('\n'); expect(utils.clean(fn), 'to be', 'var a = 1;'); }); - it('should format a multi line test indented with spaces', function() { + it('should format a multi line test indented with spaces', function () { // and no new lines after curly braces, shouldn't matter var fn = [ 'function(){ var a = 1;', @@ -94,7 +94,7 @@ describe('lib/utils', function() { expect(utils.clean(fn), 'to be', 'var a = 1;\n var b = 2;\nvar c = 3;'); }); - it('should format a multi line test indented with tabs', function() { + it('should format a multi line test indented with tabs', function () { var fn = [ 'function (arg1, arg2) {', '\tif (true) {', @@ -105,7 +105,7 @@ describe('lib/utils', function() { expect(utils.clean(fn), 'to be', 'if (true) {\n\tvar a = 1;\n}'); }); - it('should format functions saved in windows style - spaces', function() { + it('should format functions saved in windows style - spaces', function () { var fn = [ 'function (one) {', ' do {', @@ -116,7 +116,7 @@ describe('lib/utils', function() { expect(utils.clean(fn), 'to be', 'do {\n "nothing";\n} while (false);'); }); - it('should format functions saved in windows style - tabs', function() { + it('should format functions saved in windows style - tabs', function () { var fn = [ 'function ( ) {', '\tif (false) {', @@ -133,21 +133,21 @@ describe('lib/utils', function() { ); }); - it('should format es6 arrow functions', function() { + it('should format es6 arrow functions', function () { var fn = ['() => {', ' var a = 1;', '}'].join('\n'); expect(utils.clean(fn), 'to be', 'var a = 1;'); }); - it('should format es6 arrow functions with implicit return', function() { + it('should format es6 arrow functions with implicit return', function () { var fn = '() => foo()'; expect(utils.clean(fn), 'to be', 'foo()'); }); }); - describe('stringify()', function() { + describe('stringify()', function () { var stringify = utils.stringify; - it('should return an object representation of a string created with a String constructor', function() { + it('should return an object representation of a string created with a String constructor', function () { /* eslint no-new-wrappers: off */ expect( stringify(new String('foo')), @@ -156,7 +156,7 @@ describe('lib/utils', function() { ); }); - it('should return Buffer with .toJSON representation', function() { + it('should return Buffer with .toJSON representation', function () { expect(stringify(Buffer.from([0x01])), 'to be', '[\n 1\n]'); expect(stringify(Buffer.from([0x01, 0x02])), 'to be', '[\n 1\n 2\n]'); @@ -167,7 +167,7 @@ describe('lib/utils', function() { ); }); - it('should return Date object with .toISOString() + string prefix', function() { + it('should return Date object with .toISOString() + string prefix', function () { expect( stringify(new Date(0)), 'to be', @@ -178,7 +178,7 @@ describe('lib/utils', function() { expect(stringify(date), 'to be', '[Date: ' + date.toISOString() + ']'); }); - it('should return invalid Date object with .toString() + string prefix', function() { + it('should return invalid Date object with .toString() + string prefix', function () { expect( stringify(new Date('')), 'to be', @@ -186,35 +186,35 @@ describe('lib/utils', function() { ); }); - describe('#Number', function() { - it('should show the handle -0 situations', function() { + describe('#Number', function () { + it('should show the handle -0 situations', function () { expect(stringify(-0), 'to be', '-0'); expect(stringify(0), 'to be', '0'); expect(stringify('-0'), 'to be', '"-0"'); }); - it('should work well with `NaN` and `Infinity`', function() { + it('should work well with `NaN` and `Infinity`', function () { expect(stringify(NaN), 'to be', 'NaN'); expect(stringify(Infinity), 'to be', 'Infinity'); expect(stringify(-Infinity), 'to be', '-Infinity'); }); - it('floats and ints', function() { + it('floats and ints', function () { expect(stringify(1), 'to be', '1'); expect(stringify(1.2), 'to be', '1.2'); expect(stringify(1e9), 'to be', '1000000000'); }); if (typeof BigInt === 'function') { - it('should work with bigints when possible', function() { + it('should work with bigints when possible', function () { expect(stringify(BigInt(1)), 'to be', '1n'); expect(stringify(BigInt(2)), 'to be', '2n'); }); } }); - describe('canonicalize example', function() { - it('should represent the actual full result', function() { + describe('canonicalize example', function () { + it('should represent the actual full result', function () { var expected = { str: 'string', int: 90, @@ -224,7 +224,7 @@ describe('lib/utils', function() { undef: undefined, regex: /^[a-z|A-Z]/, date: new Date(0), - func: function() {}, + func: function () {}, infi: Infinity, nan: NaN, zero: -0, @@ -290,14 +290,14 @@ describe('lib/utils', function() { }); }); - it('should canonicalize the object', function() { + it('should canonicalize the object', function () { var travis = {name: 'travis', age: 24}; var travis2 = {age: 24, name: 'travis'}; expect(stringify(travis), 'to be', stringify(travis2)); }); - it('should handle circular structures in objects', function() { + it('should handle circular structures in objects', function () { var travis = {name: 'travis'}; travis.whoami = travis; @@ -308,21 +308,21 @@ describe('lib/utils', function() { ); }); - it('should handle circular structures in arrays', function() { + it('should handle circular structures in arrays', function () { var travis = ['travis']; travis.push(travis); expect(stringify(travis), 'to be', '[\n "travis"\n [Circular]\n]'); }); - it('should handle circular structures in functions', function() { - var travis = function() {}; + it('should handle circular structures in functions', function () { + var travis = function () {}; travis.fn = travis; expect(stringify(travis), 'to be', '{\n "fn": [Circular]\n}'); }); - it('should handle various non-undefined, non-null, non-object, non-array, non-date, and non-function values', function() { + it('should handle various non-undefined, non-null, non-object, non-array, non-date, and non-function values', function () { var regexp = /(?:)/; var regExpObj = {regexp: regexp}; var regexpString = '/(?:)/'; @@ -370,7 +370,7 @@ describe('lib/utils', function() { expect(stringify(nullValue), 'to be', nullString); }); - it('should handle arrays', function() { + it('should handle arrays', function () { var array = ['dave', 'dave', 'dave', 'dave']; var arrayObj = {array: array}; var arrayString = ' "dave"\n "dave"\n "dave"\n "dave"'; @@ -387,8 +387,8 @@ describe('lib/utils', function() { ); }); - it('should handle functions', function() { - var fn = function() {}; + it('should handle functions', function () { + var fn = function () {}; var fnObj = {fn: fn}; var fnString = '[Function]'; @@ -396,40 +396,40 @@ describe('lib/utils', function() { expect(stringify(fn), 'to be', '[Function]'); }); - it('should handle empty objects', function() { + it('should handle empty objects', function () { expect(stringify({}), 'to be', '{}'); expect(stringify({foo: {}}), 'to be', '{\n "foo": {}\n}'); }); - it('should handle empty arrays', function() { + it('should handle empty arrays', function () { expect(stringify([]), 'to be', '[]'); expect(stringify({foo: []}), 'to be', '{\n "foo": []\n}'); }); - it('should handle non-empty arrays', function() { + it('should handle non-empty arrays', function () { expect(stringify(['a', 'b', 'c']), 'to be', '[\n "a"\n "b"\n "c"\n]'); }); - it('should handle empty functions (with no properties)', function() { + it('should handle empty functions (with no properties)', function () { expect( - stringify(function() {}), + stringify(function () {}), 'to be', '[Function]' ); expect( - stringify({foo: function() {}}), + stringify({foo: function () {}}), 'to be', '{\n "foo": [Function]\n}' ); expect( - stringify({foo: function() {}, bar: 'baz'}), + stringify({foo: function () {}, bar: 'baz'}), 'to be', '{\n "bar": "baz"\n "foo": [Function]\n}' ); }); - it('should handle functions w/ properties', function() { - var fn = function() {}; + it('should handle functions w/ properties', function () { + var fn = function () {}; fn.bar = 'baz'; expect(stringify(fn), 'to be', '{\n "bar": "baz"\n}'); expect( @@ -439,7 +439,7 @@ describe('lib/utils', function() { ); }); - it('should handle undefined values', function() { + it('should handle undefined values', function () { expect( stringify({foo: undefined}), 'to be', @@ -453,7 +453,7 @@ describe('lib/utils', function() { expect(stringify(), 'to be', '[undefined]'); }); - it('should recurse', function() { + it('should recurse', function () { expect( stringify({foo: {bar: {baz: {quux: {herp: 'derp'}}}}}), 'to be', @@ -461,11 +461,11 @@ describe('lib/utils', function() { ); }); - it('might get confusing', function() { + it('might get confusing', function () { expect(stringify(null), 'to be', '[null]'); }); - it('should not freak out if it sees a primitive twice', function() { + it('should not freak out if it sees a primitive twice', function () { expect( stringify({foo: null, bar: null}), 'to be', @@ -478,7 +478,7 @@ describe('lib/utils', function() { ); }); - it('should stringify dates', function() { + it('should stringify dates', function () { var date = new Date(0); expect(stringify(date), 'to be', '[Date: 1970-01-01T00:00:00.000Z]'); expect( @@ -488,7 +488,7 @@ describe('lib/utils', function() { ); }); - it('should handle object without an Object prototype', function() { + it('should handle object without an Object prototype', function () { var a; if (Object.create) { a = Object.create(null); @@ -502,7 +502,7 @@ describe('lib/utils', function() { // In old version node.js, Symbol is not available by default. if (typeof global.Symbol === 'function') { - it('should handle Symbol', function() { + it('should handle Symbol', function () { var symbol = Symbol('value'); expect(stringify(symbol), 'to match', /^Symbol\(value\)/); expect( @@ -513,7 +513,7 @@ describe('lib/utils', function() { }); } - it('should handle length properties that cannot be coerced to a number', function() { + it('should handle length properties that cannot be coerced to a number', function () { expect( stringify({length: {nonBuiltinProperty: 0}}), 'to be', @@ -527,15 +527,15 @@ describe('lib/utils', function() { }); }); - describe('type()', function() { + describe('type()', function () { /* eslint no-extend-native: off */ var type = utils.type; var toString = Object.prototype.toString; - beforeEach(function() { + beforeEach(function () { // some JS engines such as PhantomJS 1.x exhibit this behavior - Object.prototype.toString = function() { + Object.prototype.toString = function () { if (this === global) { return '[object DOMWindow]'; } @@ -543,7 +543,7 @@ describe('lib/utils', function() { }; }); - it('should recognize various types', function() { + it('should recognize various types', function () { expect(type({}), 'to be', 'object'); expect(type([]), 'to be', 'array'); expect(type(1), 'to be', 'number'); @@ -569,27 +569,27 @@ describe('lib/utils', function() { ); }); - describe('when toString on null or undefined stringifies window', function() { - it('should recognize null and undefined', function() { + describe('when toString on null or undefined stringifies window', function () { + it('should recognize null and undefined', function () { expect(type(null), 'to be', 'null'); expect(type(undefined), 'to be', 'undefined'); }); }); - afterEach(function() { + afterEach(function () { Object.prototype.toString = toString; }); }); - describe('canonicalType()', function() { + describe('canonicalType()', function () { /* eslint no-extend-native: off */ var type = utils.canonicalType; var toString = Object.prototype.toString; - beforeEach(function() { + beforeEach(function () { // some JS engines such as PhantomJS 1.x exhibit this behavior - Object.prototype.toString = function() { + Object.prototype.toString = function () { if (this === global) { return '[object DOMWindow]'; } @@ -597,7 +597,7 @@ describe('lib/utils', function() { }; }); - it('should recognize various types', function() { + it('should recognize various types', function () { expect(type({}), 'to be', 'object'); expect(type([]), 'to be', 'array'); expect(type(1), 'to be', 'number'); @@ -611,44 +611,44 @@ describe('lib/utils', function() { expect(type(true), 'to be', 'boolean'); }); - describe('when toString on null or undefined stringifies window', function() { - it('should recognize null and undefined', function() { + describe('when toString on null or undefined stringifies window', function () { + it('should recognize null and undefined', function () { expect(type(null), 'to be', 'null'); expect(type(undefined), 'to be', 'undefined'); }); }); - afterEach(function() { + afterEach(function () { Object.prototype.toString = toString; }); }); - describe('isPromise()', function() { - it('should return true if the value is Promise-ish', function() { + describe('isPromise()', function () { + it('should return true if the value is Promise-ish', function () { expect( utils.isPromise({ - then: function() {} + then: function () {} }), 'to be', true ); }); - it('should return false if the value is not an object', function() { + it('should return false if the value is not an object', function () { expect(utils.isPromise(1), 'to be', false); }); - it('should return false if the value is an object w/o a "then" function', function() { + it('should return false if the value is an object w/o a "then" function', function () { expect(utils.isPromise({}), 'to be', false); }); - it('should return false if the object is null', function() { + it('should return false if the object is null', function () { expect(utils.isPromise(null), 'to be', false); }); }); - describe('escape()', function() { - it('replaces the usual xml suspects', function() { + describe('escape()', function () { + it('replaces the usual xml suspects', function () { expect(utils.escape('a>bc>d>'), 'to be', '>a>bc>d>'); expect(utils.escape('"a"bc"d"'), 'to be', '"a"bc"d"'); @@ -658,7 +658,7 @@ describe('lib/utils', function() { expect(utils.escape('&<'), 'to be', '&amp;&lt;'); }); - it('replaces invalid xml characters', function() { + it('replaces invalid xml characters', function () { expect( utils.escape('\x1B[32mfoo\x1B[0m'), 'to be', @@ -669,18 +669,18 @@ describe('lib/utils', function() { }); }); - describe('createMap()', function() { - it('should return an object with a null prototype', function() { + describe('createMap()', function () { + it('should return an object with a null prototype', function () { expect(Object.getPrototypeOf(utils.createMap()), 'to be', null); }); - it('should add props to the object', function() { + it('should add props to the object', function () { expect(utils.createMap({foo: 'bar'}), 'to exhaustively satisfy', { foo: 'bar' }); }); - it('should add props from all object parameters to the object', function() { + it('should add props from all object parameters to the object', function () { expect( utils.createMap({foo: 'bar'}, {bar: 'baz'}), 'to exhaustively satisfy', @@ -689,12 +689,12 @@ describe('lib/utils', function() { }); }); - describe('slug()', function() { - it('should convert the string to lowercase', function() { + describe('slug()', function () { + it('should convert the string to lowercase', function () { expect(utils.slug('FOO'), 'to be', 'foo'); }); - it('should convert whitespace to dashes', function() { + it('should convert whitespace to dashes', function () { expect( utils.slug('peanut butter\nand\tjelly'), 'to be', @@ -702,18 +702,18 @@ describe('lib/utils', function() { ); }); - it('should strip non-alphanumeric and non-dash characters', function() { + it('should strip non-alphanumeric and non-dash characters', function () { expect(utils.slug('murder-hornets!!'), 'to be', 'murder-hornets'); }); - it('should disallow consecutive dashes', function() { + it('should disallow consecutive dashes', function () { expect(utils.slug('poppies & fritz'), 'to be', 'poppies-fritz'); }); }); - describe('castArray()', function() { - describe('when provided an array value', function() { - it('should return a copy of the array', function() { + describe('castArray()', function () { + describe('when provided an array value', function () { + it('should return a copy of the array', function () { const v = ['foo', 'bar', 'baz']; expect(utils.castArray(v), 'to equal', ['foo', 'bar', 'baz']).and( 'not to be', @@ -722,9 +722,9 @@ describe('lib/utils', function() { }); }); - describe('when provided an "arguments" value', function() { - it('should return an array containing the arguments', function() { - (function() { + describe('when provided an "arguments" value', function () { + it('should return an array containing the arguments', function () { + (function () { expect(utils.castArray(arguments), 'to equal', [ 'foo', 'bar', @@ -734,34 +734,34 @@ describe('lib/utils', function() { }); }); - describe('when provided an object', function() { - it('should return an array containing the object only', function() { + describe('when provided an object', function () { + it('should return an array containing the object only', function () { const v = {foo: 'bar'}; expect(utils.castArray(v), 'to equal', [v]); }); }); - describe('when provided no parameters', function() { - it('should return an empty array', function() { + describe('when provided no parameters', function () { + it('should return an empty array', function () { expect(utils.castArray(), 'to equal', []); }); }); - describe('when provided a primitive value', function() { - it('should return an array containing the primitive value only', function() { + describe('when provided a primitive value', function () { + it('should return an array containing the primitive value only', function () { expect(utils.castArray('butts'), 'to equal', ['butts']); }); }); - describe('when provided null', function() { - it('should return an array containing a null value only', function() { + describe('when provided null', function () { + it('should return an array containing a null value only', function () { expect(utils.castArray(null), 'to equal', [null]); }); }); }); - describe('uniqueID()', function() { - it('should return a non-empty string', function() { + describe('uniqueID()', function () { + it('should return a non-empty string', function () { expect(utils.uniqueID(), 'to be a string').and('not to be empty'); }); });