diff --git a/lib/config.js b/lib/config.js index deeaf6d7d..5338906d2 100644 --- a/lib/config.js +++ b/lib/config.js @@ -284,7 +284,7 @@ var Config = function () { this.LOG_DEBUG = constant.LOG_DEBUG this.set = function (newConfig) { - _.merge(config, newConfig, function (obj, src) { + _.mergeWith(config, newConfig, function (obj, src) { // Overwrite arrays to keep consistent with #283 if (_.isArray(src)) { return src diff --git a/lib/helper.js b/lib/helper.js index 76179d2c5..e0b32c8ac 100644 --- a/lib/helper.js +++ b/lib/helper.js @@ -166,11 +166,3 @@ exports.defer = function () { promise: promise } } - -// export lodash -Object.defineProperty(exports, '_', { - get: function () { - console.log('DEPRECATED: use your own version of lodash, this will go away in karma@2.0') - return _ - } -}) diff --git a/package.json b/package.json index df7ab1f9a..73f45f0f2 100644 --- a/package.json +++ b/package.json @@ -340,8 +340,8 @@ "graceful-fs": "^4.1.2", "http-proxy": "^1.13.0", "isbinaryfile": "^3.0.0", - "lodash": "^3.8.0", - "log4js": "^0.6.31", + "lodash": "^4.17.4", + "log4js": "^1.1.1", "mime": "^1.3.4", "minimatch": "^3.0.2", "optimist": "^0.6.1", @@ -363,12 +363,14 @@ "chai-as-promised": "^6.0.0", "chai-subset": "^1.2.2", "coffee-script": "^1.12.4", - "cucumber": "^1.2.0", + "cucumber": "^2.2.0", "eslint": "^3.15.0", - "eslint-config-standard": "^7.0.0", + "eslint-config-standard": "^10.2.1", + "eslint-plugin-import": "^2.2.0", + "eslint-plugin-node": "^4.2.2", "eslint-plugin-promise": "^3.4.2", - "eslint-plugin-react": "^6.10.0", - "eslint-plugin-standard": "^2.0.1", + "eslint-plugin-react": "^7.0.1", + "eslint-plugin-standard": "^3.0.1", "grunt": "^1.0.0", "grunt-auto-release": "^0.0.7", "grunt-browserify": "^5.0.0", @@ -414,7 +416,7 @@ "proxyquire": "^1.7.11", "qunitjs": "^2.1.1", "requirejs": "^2.1.20", - "sinon": "^1.17.5", + "sinon": "^2.2.0", "sinon-chai": "^2.7.0", "supertest": "^3.0.0", "timer-shim": "^0.3.0", diff --git a/test/unit/completion.spec.js b/test/unit/completion.spec.js index c39217bc6..33f66ee9b 100644 --- a/test/unit/completion.spec.js +++ b/test/unit/completion.spec.js @@ -15,7 +15,7 @@ describe('completion', () => { } beforeEach(() => { - sinon.stub(console, 'log', (msg) => completion.push(msg)) + sinon.stub(console, 'log').callsFake((msg) => completion.push(msg)) completion = [] }) diff --git a/test/unit/config.spec.js b/test/unit/config.spec.js index 288343f54..0f2dc5783 100644 --- a/test/unit/config.spec.js +++ b/test/unit/config.spec.js @@ -1,5 +1,5 @@ -var loadFile = require('mocks').loadFile import path from 'path' +var loadFile = require('mocks').loadFile var helper = require('../../lib/helper') var logger = require('../../lib/logger.js') diff --git a/test/unit/file-list.spec.js b/test/unit/file-list.spec.js index 53c1340ec..41bb58e48 100644 --- a/test/unit/file-list.spec.js +++ b/test/unit/file-list.spec.js @@ -13,7 +13,7 @@ import config from '../../lib/config' var patterns = (...strings) => strings.map((str) => new config.Pattern(str)) function pathsFrom (files) { - return _.pluck(from(files), 'path') + return _.map(from(files), 'path') } function findFile (path, files) { @@ -279,7 +279,7 @@ describe('FileList', () => { it('cancels refreshs', () => { var checkResult = (files) => { - expect(_.pluck(files.served, 'path')).to.contain('/some/a.js', '/some/b.js', '/some/c.js') + expect(_.map(files.served, 'path')).to.contain('/some/a.js', '/some/b.js', '/some/c.js') } var p1 = list.refresh().then(checkResult) @@ -900,7 +900,7 @@ describe('FileList', () => { }) }) - it('waits while file preprocessing, if the file was deleted and immediately added', (done) => { + it('waits while file preprocessing, if the file was deleted and immediately added', () => { list = new List(patterns('/a.*'), [], emitter, preprocess, 100) list.refresh().then((files) => { @@ -915,12 +915,25 @@ describe('FileList', () => { expect(preprocess).to.not.have.been.called - emitter.once('file_list_modified', () => _.defer(() => { - expect(preprocess).to.have.been.calledOnce - done() - })) + var promise = new Promise((resolve) => { + emitter.once('file_list_modified', () => _.defer(() => { + resolve() + })) + }) clock.tick(2) + + return promise + .then(() => { + return new Promise((resolve) => { + _.defer(() => { + resolve() + }) + }) + }) + .then(() => { + expect(preprocess).to.have.been.calledOnce + }) }) }) }) diff --git a/test/unit/launcher.spec.js b/test/unit/launcher.spec.js index 81e11031f..aa3662599 100644 --- a/test/unit/launcher.spec.js +++ b/test/unit/launcher.spec.js @@ -10,7 +10,7 @@ var stubPromise = (obj, method, stubAction) => { obj[method].resolve = resolve }) - sinon.stub(obj, method, () => { + sinon.stub(obj, method).callsFake(() => { if (stubAction) stubAction() return promise @@ -30,7 +30,7 @@ class FakeBrowser { baseBrowserDecorator(this) FakeBrowser._instances.push(this) - sinon.stub(this, 'start', () => { + sinon.stub(this, 'start').callsFake(() => { this.state = this.STATE_BEING_CAPTURED this._done() }) @@ -52,7 +52,7 @@ class ScriptBrowser { baseBrowserDecorator(this) ScriptBrowser._instances.push(this) - sinon.stub(this, 'start', () => { + sinon.stub(this, 'start').callsFake(() => { this.state = this.STATE_BEING_CAPTURED this._done() }) diff --git a/test/unit/logger.spec.js b/test/unit/logger.spec.js index 873ba3c5a..b8b92f737 100644 --- a/test/unit/logger.spec.js +++ b/test/unit/logger.spec.js @@ -15,7 +15,7 @@ describe('logger', () => { filename: 'test/unit/test.log' }]) - expect(m.log4js.appenders).to.have.keys(['console', 'file']) + expect(m.log4js.appenders).to.have.keys(['console', 'file', 'stdout']) }) }) }) diff --git a/test/unit/middleware/runner.spec.js b/test/unit/middleware/runner.spec.js index 4961d2683..e773f1c26 100644 --- a/test/unit/middleware/runner.spec.js +++ b/test/unit/middleware/runner.spec.js @@ -70,7 +70,7 @@ describe('middleware.runner', () => { it('should trigger test run and stream the reporter', (done) => { capturedBrowsers.add(new Browser()) - sinon.stub(capturedBrowsers, 'areAllReady', () => true) + sinon.stub(capturedBrowsers, 'areAllReady').callsFake(() => true) response.once('end', () => { expect(nextSpy).to.not.have.been.called @@ -86,7 +86,7 @@ describe('middleware.runner', () => { it('should set the empty to 0 if empty results', (done) => { capturedBrowsers.add(new Browser()) - sinon.stub(capturedBrowsers, 'areAllReady', () => true) + sinon.stub(capturedBrowsers, 'areAllReady').callsFake(() => true) response.once('end', () => { expect(nextSpy).to.not.have.been.called @@ -102,7 +102,7 @@ describe('middleware.runner', () => { it('should set the empty to 1 if successful tests', (done) => { capturedBrowsers.add(new Browser()) - sinon.stub(capturedBrowsers, 'areAllReady', () => true) + sinon.stub(capturedBrowsers, 'areAllReady').callsFake(() => true) response.once('end', () => { expect(nextSpy).to.not.have.been.called @@ -118,7 +118,7 @@ describe('middleware.runner', () => { it('should set the empty to 1 if failed tests', (done) => { capturedBrowsers.add(new Browser()) - sinon.stub(capturedBrowsers, 'areAllReady', () => true) + sinon.stub(capturedBrowsers, 'areAllReady').callsFake(() => true) response.once('end', () => { expect(nextSpy).to.not.have.been.called @@ -215,7 +215,7 @@ describe('middleware.runner', () => { clientArgsRuns.forEach(function (run) { it(run.desc, (done) => { capturedBrowsers.add(new Browser()) - sinon.stub(capturedBrowsers, 'areAllReady', () => true) + sinon.stub(capturedBrowsers, 'areAllReady').callsFake(() => true) if (run.existingConfig) { config = _.merge(config, {client: {args: run.existingConfig}}) } @@ -242,7 +242,7 @@ describe('middleware.runner', () => { it('should refresh explicit files if specified', (done) => { capturedBrowsers.add(new Browser()) - sinon.stub(capturedBrowsers, 'areAllReady', () => true) + sinon.stub(capturedBrowsers, 'areAllReady').callsFake(() => true) sinon.stub(fileListMock, 'refresh') sinon.stub(fileListMock, 'addFile') sinon.stub(fileListMock, 'changeFile') @@ -276,7 +276,7 @@ describe('middleware.runner', () => { it('should wait for refresh to finish if applicable before scheduling execution', (done) => { capturedBrowsers.add(new Browser()) - sinon.stub(capturedBrowsers, 'areAllReady', () => true) + sinon.stub(capturedBrowsers, 'areAllReady').callsFake(() => true) var res = null var fileListPromise = new Promise((resolve, reject) => { @@ -303,7 +303,7 @@ describe('middleware.runner', () => { it('should schedule execution if no refresh', (done) => { capturedBrowsers.add(new Browser()) - sinon.stub(capturedBrowsers, 'areAllReady', () => true) + sinon.stub(capturedBrowsers, 'areAllReady').callsFake(() => true) sinon.spy(fileListMock, 'refresh') sinon.stub(executor, 'schedule') @@ -331,7 +331,7 @@ describe('middleware.runner', () => { config.autoWatch = true capturedBrowsers.add(new Browser()) - sinon.stub(capturedBrowsers, 'areAllReady', () => true) + sinon.stub(capturedBrowsers, 'areAllReady').callsFake(() => true) sinon.spy(fileListMock, 'refresh') sinon.stub(executor, 'schedule') diff --git a/test/unit/preprocessor.spec.js b/test/unit/preprocessor.spec.js index c0974e6a1..2de625023 100644 --- a/test/unit/preprocessor.spec.js +++ b/test/unit/preprocessor.spec.js @@ -9,7 +9,7 @@ describe('preprocessor', () => { var mockFs var emitterSetting // mimic first few bytes of a pdf file - var binarydata = new Buffer([0x25, 0x50, 0x44, 0x66, 0x46, 0x00]) + var binarydata = new Buffer([0x25, 0x50, 0x44, 0x66, 0x46, 0x00]) // eslint-disable-line node/no-deprecated-api beforeEach(() => { mockFs = mocks.fs.create({ diff --git a/test/unit/runner.spec.js b/test/unit/runner.spec.js index 68d45491e..98fcb2118 100644 --- a/test/unit/runner.spec.js +++ b/test/unit/runner.spec.js @@ -13,12 +13,12 @@ describe('runner', () => { var EXIT = constant.EXIT_CODE it('should return 0 exit code if present in the buffer', () => { - var result = m.parseExitCode(new Buffer(`something\nfake${EXIT}10`)) + var result = m.parseExitCode(new Buffer(`something\nfake${EXIT}10`)) // eslint-disable-line node/no-deprecated-api expect(result.exitCode).to.equal(0) }) it('should remove the exit code part of the returned buffer', () => { - var buffer = new Buffer(`some${EXIT}01`) + var buffer = new Buffer(`some${EXIT}01`) // eslint-disable-line node/no-deprecated-api var result = m.parseExitCode(buffer) expect(buffer.toString()).to.equal(`some${EXIT}01`) @@ -27,7 +27,7 @@ describe('runner', () => { it('should not touch buffer without exit code and return default', () => { var msg = 'some nice \n messgae {}' - var buffer = new Buffer(msg) + var buffer = new Buffer(msg) // eslint-disable-line node/no-deprecated-api var result = m.parseExitCode(buffer, 10) expect(result.buffer.toString()).to.equal(msg) @@ -52,21 +52,21 @@ describe('runner', () => { }) it('should parse any single digit exit code', () => { - expect(m.parseExitCode(new Buffer(`something\nfake${EXIT}01`)).exitCode).to.equal(1) - expect(m.parseExitCode(new Buffer(`something\nfake${EXIT}17`)).exitCode).to.equal(7) + expect(m.parseExitCode(new Buffer(`something\nfake${EXIT}01`)).exitCode).to.equal(1) // eslint-disable-line node/no-deprecated-api + expect(m.parseExitCode(new Buffer(`something\nfake${EXIT}17`)).exitCode).to.equal(7) // eslint-disable-line node/no-deprecated-api }) it('should return exit code 0 if failOnEmptyTestSuite is false and and non-empty int is 0', () => { - expect(m.parseExitCode(new Buffer(`something\nfake${EXIT}01`), undefined, false).exitCode).to.equal(0) + expect(m.parseExitCode(new Buffer(`something\nfake${EXIT}01`), undefined, false).exitCode).to.equal(0) // eslint-disable-line node/no-deprecated-api }) it('should return exit code if failOnEmptyTestSuite is true', () => { - expect(m.parseExitCode(new Buffer(`something\nfake${EXIT}00`), undefined, true).exitCode).to.equal(0) - expect(m.parseExitCode(new Buffer(`something\nfake${EXIT}01`), undefined, true).exitCode).to.equal(1) - expect(m.parseExitCode(new Buffer(`something\nfake${EXIT}07`), undefined, true).exitCode).to.equal(7) - expect(m.parseExitCode(new Buffer(`something\nfake${EXIT}10`), undefined, true).exitCode).to.equal(0) - expect(m.parseExitCode(new Buffer(`something\nfake${EXIT}11`), undefined, true).exitCode).to.equal(1) - expect(m.parseExitCode(new Buffer(`something\nfake${EXIT}17`), undefined, true).exitCode).to.equal(7) + expect(m.parseExitCode(new Buffer(`something\nfake${EXIT}00`), undefined, true).exitCode).to.equal(0) // eslint-disable-line node/no-deprecated-api + expect(m.parseExitCode(new Buffer(`something\nfake${EXIT}01`), undefined, true).exitCode).to.equal(1) // eslint-disable-line node/no-deprecated-api + expect(m.parseExitCode(new Buffer(`something\nfake${EXIT}07`), undefined, true).exitCode).to.equal(7) // eslint-disable-line node/no-deprecated-api + expect(m.parseExitCode(new Buffer(`something\nfake${EXIT}10`), undefined, true).exitCode).to.equal(0) // eslint-disable-line node/no-deprecated-api + expect(m.parseExitCode(new Buffer(`something\nfake${EXIT}11`), undefined, true).exitCode).to.equal(1) // eslint-disable-line node/no-deprecated-api + expect(m.parseExitCode(new Buffer(`something\nfake${EXIT}17`), undefined, true).exitCode).to.equal(7) // eslint-disable-line node/no-deprecated-api }) }) }) diff --git a/test/unit/server.spec.js b/test/unit/server.spec.js index ec8edef8c..248ad1f4b 100644 --- a/test/unit/server.spec.js +++ b/test/unit/server.spec.js @@ -230,7 +230,7 @@ describe('server', () => { fileListOnResolve() function mockProcess (process) { - sinon.stub(process, 'kill', (pid, ev) => process.emit(ev)) + sinon.stub(process, 'kill').callsFake((pid, ev) => process.emit(ev)) } }) }) diff --git a/test/unit/web-server.spec.js b/test/unit/web-server.spec.js index 51ee479da..651eb470e 100644 --- a/test/unit/web-server.spec.js +++ b/test/unit/web-server.spec.js @@ -1,4 +1,4 @@ -require('core-js') +import 'core-js' import {EventEmitter} from 'events' import request from 'supertest' import di from 'di'