diff --git a/.eslintignore b/.eslintignore index 1ce4437ab5..7adc61c7f0 100644 --- a/.eslintignore +++ b/.eslintignore @@ -2,3 +2,4 @@ coverage/ lib/to-iso-string/**/*.js mocha.js BUILDTMP +*.fixture.js diff --git a/.travis.yml b/.travis.yml index f475c66b1f..7e849ccc35 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,18 +21,8 @@ matrix: env: TARGET=test-node - node_js: '6' env: TARGET=test-node - - node_js: '5' - env: TARGET=test-node - node_js: '4' env: TARGET=test-node - - node_js: 'iojs' - env: TARGET=test-node - - node_js: '0.12' - env: TARGET=test-node - - node_js: '0.11' - env: TARGET=test-node - - node_js: '0.10' - env: TARGET=test-node - node_js: '8' env: TARGET=lint # phantomjs diff --git a/Makefile b/Makefile index c31e59fabe..333086277d 100644 --- a/Makefile +++ b/Makefile @@ -77,11 +77,12 @@ test-compilers: $(call test_node,compilers-coffee) --compilers coffee:coffee-script/register \ test/compiler - $(call test_node,compilers-custom) --compilers foo:./test/compiler-fixtures/foo \ + $(call test_node,compilers-custom) \ + --compilers foo:./test/compiler-fixtures/foo.fixture \ test/compiler $(call test_node,compilers-multiple) \ - --compilers coffee:coffee-script/register,foo:./test/compiler-fixtures/foo \ + --compilers coffee:coffee-script/register,foo:./test/compiler-fixtures/foo.fixture \ test/compiler test-requires: diff --git a/appveyor.yml b/appveyor.yml index ff832db835..2fe1c21c65 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -4,8 +4,6 @@ environment: - nodejs_version: '7' - nodejs_version: '6' - nodejs_version: '4' - - nodejs_version: '0.12' - - nodejs_version: '0.10' install: - ps: Install-Product node $env:nodejs_version - set CI=true diff --git a/lib/browser/debug.js b/lib/browser/debug.js deleted file mode 100644 index 3d12160f1a..0000000000 --- a/lib/browser/debug.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -function noop () {} - -module.exports = function () { - return noop; -}; diff --git a/lib/browser/events.js b/lib/browser/events.js deleted file mode 100644 index e46a9f5f05..0000000000 --- a/lib/browser/events.js +++ /dev/null @@ -1,195 +0,0 @@ -'use strict'; - -/** - * Module exports. - */ - -exports.EventEmitter = EventEmitter; - -/** - * Object#toString reference. - */ -var objToString = Object.prototype.toString; - -/** - * Check if a value is an array. - * - * @api private - * @param {*} val The value to test. - * @return {boolean} true if the value is an array, otherwise false. - */ -function isArray (val) { - return objToString.call(val) === '[object Array]'; -} - -/** - * Event emitter constructor. - * - * @api public - */ -function EventEmitter () {} - -/** - * Add a listener. - * - * @api public - * @param {string} name Event name. - * @param {Function} fn Event handler. - * @return {EventEmitter} Emitter instance. - */ -EventEmitter.prototype.on = function (name, fn) { - if (!this.$events) { - this.$events = {}; - } - - if (!this.$events[name]) { - this.$events[name] = fn; - } else if (isArray(this.$events[name])) { - this.$events[name].push(fn); - } else { - this.$events[name] = [this.$events[name], fn]; - } - - return this; -}; - -EventEmitter.prototype.addListener = EventEmitter.prototype.on; - -/** - * Adds a volatile listener. - * - * @api public - * @param {string} name Event name. - * @param {Function} fn Event handler. - * @return {EventEmitter} Emitter instance. - */ -EventEmitter.prototype.once = function (name, fn) { - var self = this; - - function on () { - self.removeListener(name, on); - fn.apply(this, arguments); - } - - on.listener = fn; - this.on(name, on); - - return this; -}; - -/** - * Remove a listener. - * - * @api public - * @param {string} name Event name. - * @param {Function} fn Event handler. - * @return {EventEmitter} Emitter instance. - */ -EventEmitter.prototype.removeListener = function (name, fn) { - if (this.$events && this.$events[name]) { - var list = this.$events[name]; - - if (isArray(list)) { - var pos = -1; - - for (var i = 0, l = list.length; i < l; i++) { - if (list[i] === fn || (list[i].listener && list[i].listener === fn)) { - pos = i; - break; - } - } - - if (pos < 0) { - return this; - } - - list.splice(pos, 1); - - if (!list.length) { - delete this.$events[name]; - } - } else if (list === fn || (list.listener && list.listener === fn)) { - delete this.$events[name]; - } - } - - return this; -}; - -/** - * Remove all listeners for an event. - * - * @api public - * @param {string} name Event name. - * @return {EventEmitter} Emitter instance. - */ -EventEmitter.prototype.removeAllListeners = function (name) { - if (name === undefined) { - this.$events = {}; - return this; - } - - if (this.$events && this.$events[name]) { - this.$events[name] = null; - } - - return this; -}; - -/** - * Get all listeners for a given event. - * - * @api public - * @param {string} name Event name. - * @return {EventEmitter} Emitter instance. - */ -EventEmitter.prototype.listeners = function (name) { - if (!this.$events) { - this.$events = {}; - } - - if (!this.$events[name]) { - this.$events[name] = []; - } - - if (!isArray(this.$events[name])) { - this.$events[name] = [this.$events[name]]; - } - - return this.$events[name]; -}; - -/** - * Emit an event. - * - * @api public - * @param {string} name Event name. - * @return {boolean} true if at least one handler was invoked, else false. - */ -EventEmitter.prototype.emit = function (name) { - if (!this.$events) { - return false; - } - - var handler = this.$events[name]; - - if (!handler) { - return false; - } - - var args = Array.prototype.slice.call(arguments, 1); - - if (typeof handler === 'function') { - handler.apply(this, args); - } else if (isArray(handler)) { - var listeners = handler.slice(); - - for (var i = 0, l = listeners.length; i < l; i++) { - listeners[i].apply(this, args); - } - } else { - return false; - } - - return true; -}; diff --git a/lib/browser/growl.js b/lib/browser/growl.js new file mode 100644 index 0000000000..28c62efbec --- /dev/null +++ b/lib/browser/growl.js @@ -0,0 +1,5 @@ +'use strict'; + +// just stub out growl + +module.exports = require('../utils').noop; diff --git a/lib/reporters/base.js b/lib/reporters/base.js index 5018e6f9c3..aab912e5f4 100644 --- a/lib/reporters/base.js +++ b/lib/reporters/base.js @@ -120,8 +120,8 @@ exports.window = { if (isatty) { exports.window.width = process.stdout.getWindowSize - ? process.stdout.getWindowSize(1)[0] - : tty.getWindowSize()[1]; + ? process.stdout.getWindowSize(1)[0] + : tty.getWindowSize()[1]; } /** diff --git a/lib/runner.js b/lib/runner.js index 039065a2e0..fad9a8b1f8 100644 --- a/lib/runner.js +++ b/lib/runner.js @@ -229,7 +229,7 @@ Runner.prototype.fail = function (test, err) { ++this.failures; test.state = 'failed'; - if (!(err instanceof Error || err && typeof err.message === 'string')) { + if (!((err instanceof Error || err) && typeof err.message === 'string')) { err = new Error('the ' + type(err) + ' ' + stringify(err) + ' was thrown, throw an Error :)'); } @@ -722,7 +722,7 @@ Runner.prototype.uncaught = function (err) { return; } - // recover from hooks + // recover from hooks if (runnable.type === 'hook') { var errSuite = this.suite; // if hook failure is in afterEach block diff --git a/lib/utils.js b/lib/utils.js index c40c97cd75..046e097296 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -540,8 +540,8 @@ function jsonStringify (object, spaces, depth) { --length; str += '\n ' + repeat(' ', space) + (isArray(object) ? '' : '"' + i + '": ') + // key - _stringify(object[i]) + // value - (length ? ',' : ''); // comma + _stringify(object[i]) + // value + (length ? ',' : ''); // comma } return str + diff --git a/package.json b/package.json index 8505bb4a78..3a603d37b2 100644 --- a/package.json +++ b/package.json @@ -295,8 +295,8 @@ "_mocha": "./bin/_mocha" }, "engines": { - "node": ">= 0.10.x", - "npm": ">= 1.4.x" + "node": ">= 4.0.0", + "npm": ">= 2.14.2" }, "scripts": { "lint": "eslint . bin/*", @@ -307,11 +307,11 @@ "dependencies": { "browser-stdout": "1.3.0", "commander": "2.9.0", - "debug": "2.6.8", + "debug": "2.6.9", "diff": "3.2.0", "escape-string-regexp": "1.0.5", "glob": "7.1.1", - "growl": "1.9.2", + "growl": "1.10.2", "he": "1.1.1", "json3": "3.3.2", "lodash.create": "3.1.1", @@ -325,11 +325,13 @@ "coffee-script": "^1.10.0", "coveralls": "^2.11.15", "cross-spawn": "^5.1.0", - "eslint": "^3.11.1", - "eslint-config-semistandard": "^7.0.0", - "eslint-config-standard": "^6.2.1", + "eslint": "^4.7.2", + "eslint-config-semistandard": "^11.0.0", + "eslint-config-standard": "^10.2.1", + "eslint-plugin-import": "^2.7.0", + "eslint-plugin-node": "^5.1.1", "eslint-plugin-promise": "^3.4.0", - "eslint-plugin-standard": "2.0.1", + "eslint-plugin-standard": "^3.0.1", "expect.js": "^0.3.1", "karma": "1.3.0", "karma-browserify": "^5.0.5", @@ -337,13 +339,13 @@ "karma-expect": "^1.1.2", "karma-mocha": "^1.3.0", "karma-phantomjs-launcher": "0.2.3", - "karma-spec-reporter": "0.0.26", + "karma-spec-reporter": "0.0.31", "nyc": "^11.2.1", "os-name": "^2.0.1", "phantomjs": "1.9.8", "readable-stream": "2.2.11", "rimraf": "^2.5.2", - "should": "^9.0.2", + "should": "^13.1.0", "through2": "^2.0.1", "watchify": "^3.7.0" }, @@ -359,8 +361,7 @@ "bower.json" ], "browser": { - "debug": "./lib/browser/debug.js", - "events": "./lib/browser/events.js", + "growl": "./lib/browser/growl.js", "tty": "./lib/browser/tty.js", "./index.js": "./browser-entry.js", "fs": false, diff --git a/test/.eslintrc.yaml b/test/.eslintrc.yaml index a32fd84d48..92622be761 100644 --- a/test/.eslintrc.yaml +++ b/test/.eslintrc.yaml @@ -3,3 +3,5 @@ env: globals: expect: false assert: false +rules: + no-unused-expressions: off diff --git a/test/compiler-fixtures/foo.js b/test/compiler-fixtures/foo.fixture.js similarity index 99% rename from test/compiler-fixtures/foo.js rename to test/compiler-fixtures/foo.fixture.js index 753d08e740..41f1a62808 100644 --- a/test/compiler-fixtures/foo.js +++ b/test/compiler-fixtures/foo.fixture.js @@ -1,6 +1,7 @@ 'use strict'; var fs = require('fs'); + require.extensions['.foo'] = function (module, filename) { var content; content = fs.readFileSync(filename, 'utf8'); diff --git a/test/integration/compiler-globbing.spec.js b/test/integration/compiler-globbing.spec.js index fe038229c1..ee0a7237a5 100644 --- a/test/integration/compiler-globbing.spec.js +++ b/test/integration/compiler-globbing.spec.js @@ -6,7 +6,7 @@ var path = require('path'); describe('globbing like --compilers', function () { it('should find a file of each type', function (done) { - exec('"' + process.execPath + '" "' + path.join('bin', 'mocha') + '" -R json --require coffee-script/register --require test/compiler-fixtures/foo "test/compiler/*.@(coffee|foo)"', { cwd: path.join(__dirname, '..', '..') }, function (error, stdout) { + exec('"' + process.execPath + '" "' + 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) { if (error && !stdout) { return done(error); } var results = JSON.parse(stdout); expect(results).to.have.property('tests'); diff --git a/test/integration/helpers.js b/test/integration/helpers.js index f2d9c81192..a22ce67c77 100644 --- a/test/integration/helpers.js +++ b/test/integration/helpers.js @@ -89,7 +89,7 @@ module.exports = { } else if (!diffs.length || inStackTrace) { // Haven't encountered a spec yet // or we're in the middle of a stack trace - return; + } else if (line.indexOf('+ expected - actual') !== -1) { inDiff = true; } else if (line.match(/at Context/)) { diff --git a/test/unit/utils.spec.js b/test/unit/utils.spec.js index 4ef87c60ee..3f643ea27a 100644 --- a/test/unit/utils.spec.js +++ b/test/unit/utils.spec.js @@ -164,10 +164,10 @@ describe('lib/utils', function () { }); it('should return Buffer with .toJSON representation', function () { - expect(stringify(new Buffer([0x01]))).to.equal('[\n 1\n]'); - expect(stringify(new Buffer([0x01, 0x02]))).to.equal('[\n 1\n 2\n]'); + expect(stringify(Buffer.from([0x01]))).to.equal('[\n 1\n]'); + expect(stringify(Buffer.from([0x01, 0x02]))).to.equal('[\n 1\n 2\n]'); - expect(stringify(new Buffer('ABCD'))).to.equal('[\n 65\n 66\n 67\n 68\n]'); + expect(stringify(Buffer.from('ABCD'))).to.equal('[\n 65\n 66\n 67\n 68\n]'); }); it('should return Date object with .toISOString() + string prefix', function () { @@ -224,7 +224,7 @@ describe('lib/utils', function () { infi: Infinity, nan: NaN, zero: -0, - buffer: new Buffer([0x01, 0x02]), + buffer: Buffer.from([0x01, 0x02]), array: [1, 2, 3], empArr: [], matrix: [[1], @@ -498,7 +498,7 @@ describe('lib/utils', function () { describe('isBuffer()', function () { var isBuffer = utils.isBuffer; it('should test if object is a Buffer', function () { - expect(isBuffer(new Buffer([0x01]))) + expect(isBuffer(Buffer.from([0x01]))) .to .equal(true); expect(isBuffer({}))