From 64e301b34be4f3e4f5e8647814e3a4c9db072df3 Mon Sep 17 00:00:00 2001 From: dignifiedquire Date: Thu, 18 Feb 2016 20:54:10 +0100 Subject: [PATCH] refactor: Upgrade to eslint@2 --- .eslintrc | 3 +- lib/constants.js | 3 +- lib/init/formatters.js | 11 +-- lib/plugin.js | 2 +- lib/web-server.js | 2 +- package.json | 8 +-- requirejs.config.tpl.js | 14 ++-- test/e2e/steps/core_steps.js | 2 +- test/unit/browser.spec.js | 2 +- test/unit/browser_collection.spec.js | 10 +-- test/unit/cli.spec.js | 4 +- test/unit/completion.spec.js | 2 +- test/unit/config.spec.js | 14 ++-- test/unit/emitter_wrapper.spec.js | 8 +-- test/unit/events.spec.js | 10 +-- test/unit/file-list.spec.js | 74 ++++++++++----------- test/unit/helper.spec.js | 12 ++-- test/unit/init.spec.js | 28 ++++---- test/unit/init/state_machine.spec.js | 18 ++--- test/unit/launcher.spec.js | 16 ++--- test/unit/launchers/base.spec.js | 24 +++---- test/unit/launchers/capture_timeout.spec.js | 4 +- test/unit/launchers/process.spec.js | 2 +- test/unit/logger.spec.js | 3 +- test/unit/middleware/proxy.spec.js | 3 +- test/unit/middleware/runner.spec.js | 14 ++-- test/unit/mocha-globals.js | 14 ++-- test/unit/preprocessor.spec.js | 29 ++++---- test/unit/reporter.spec.js | 17 ++--- test/unit/reporters/base.spec.js | 7 +- test/unit/runner.spec.js | 3 +- test/unit/watcher.spec.js | 2 +- test/unit/web-server.spec.js | 8 +-- 33 files changed, 190 insertions(+), 183 deletions(-) diff --git a/.eslintrc b/.eslintrc index d6622030e..e3578aadf 100644 --- a/.eslintrc +++ b/.eslintrc @@ -1,4 +1,3 @@ { - "extends": "standard", - "parser": "babel-eslint" + "extends": "standard" } diff --git a/lib/constants.js b/lib/constants.js index da974f0d2..6008a7309 100644 --- a/lib/constants.js +++ b/lib/constants.js @@ -1,6 +1,7 @@ var fs = require('graceful-fs') +var path = require('path') -var pkg = JSON.parse(fs.readFileSync(__dirname + '/../package.json').toString()) +var pkg = JSON.parse(fs.readFileSync(path.join(__dirname, '/../package.json')).toString()) exports.VERSION = pkg.version diff --git a/lib/init/formatters.js b/lib/init/formatters.js index 50251b16a..bf4a9efef 100644 --- a/lib/init/formatters.js +++ b/lib/init/formatters.js @@ -1,12 +1,13 @@ var fs = require('graceful-fs') var util = require('util') +var path = require('path') -var JS_TEMPLATE_PATH = __dirname + '/../../config.tpl.js' -var COFFEE_TEMPLATE_PATH = __dirname + '/../../config.tpl.coffee' -var JS_REQUIREJS_TEMPLATE_PATH = __dirname + '/../../requirejs.config.tpl.js' -var COFFEE_REQUIREJS_TEMPLATE_PATH = __dirname + '/../../requirejs.config.tpl.coffee' +var JS_TEMPLATE_PATH = path.join(__dirname, '/../../config.tpl.js') +var COFFEE_TEMPLATE_PATH = path.join(__dirname, '/../../config.tpl.coffee') +var JS_REQUIREJS_TEMPLATE_PATH = path.join(__dirname, '/../../requirejs.config.tpl.js') +var COFFEE_REQUIREJS_TEMPLATE_PATH = path.join(__dirname, '/../../requirejs.config.tpl.coffee') var COFFEE_REGEXP = /\.coffee$/ -var LIVE_TEMPLATE_PATH = __dirname + '/../../config.tpl.ls' +var LIVE_TEMPLATE_PATH = path.join(__dirname, '/../../config.tpl.ls') var LIVE_REGEXP = /\.ls$/ var isCoffeeFile = function (filename) { diff --git a/lib/plugin.js b/lib/plugin.js index 80e0b6d1b..a68e6d62d 100644 --- a/lib/plugin.js +++ b/lib/plugin.js @@ -26,7 +26,7 @@ exports.resolve = function (plugins) { plugins.forEach(function (plugin) { if (helper.isString(plugin)) { if (plugin.indexOf('*') !== -1) { - var pluginDirectory = path.normalize(__dirname + '/../..') + var pluginDirectory = path.normalize(path.join(__dirname, '/../..')) var regexp = new RegExp('^' + plugin.replace('*', '.*')) log.debug('Loading %s from %s', plugin, pluginDirectory) diff --git a/lib/web-server.js b/lib/web-server.js index 4dfc248c7..f84570cfa 100644 --- a/lib/web-server.js +++ b/lib/web-server.js @@ -32,7 +32,7 @@ createCustomHandler.$inject = ['customFileHandlers', 'config.basePath'] var createWebServer = function (injector, emitter, fileList) { var config = injector.get('config') common.initializeMimeTypes(config) - var serveStaticFile = common.createServeFile(fs, path.normalize(__dirname + '/../static'), config) + var serveStaticFile = common.createServeFile(fs, path.normalize(path.join(__dirname, '/../static')), config) var serveFile = common.createServeFile(fs, null, config) var filesPromise = new common.PromiseContainer() diff --git a/package.json b/package.json index 05ebc39c0..1cc304873 100644 --- a/package.json +++ b/package.json @@ -288,14 +288,14 @@ "devDependencies": { "LiveScript": "^1.3.0", "babel": "^5.6.23", - "babel-eslint": "^4.1.8", "chai": "^3.3.0", "chai-as-promised": "^5.0.0", "chai-subset": "^1.0.1", "coffee-script": "^1.9.2", "cucumber": "^0.9.1", - "eslint": "^1.0.0", - "eslint-config-standard": "^4.0.0", + "eslint": "^2.1.0", + "eslint-config-standard": "^5.1.0", + "eslint-plugin-promise": "^1.0.8", "eslint-plugin-react": "^3.15.0", "eslint-plugin-standard": "^1.3.1", "ghooks": "^1.0.3", @@ -308,7 +308,7 @@ "grunt-conventional-changelog": "^6.0.1", "grunt-conventional-github-releaser": "^0.5.0", "grunt-cucumberjs": "^0.8.7", - "grunt-eslint": "^17.0.0", + "grunt-eslint": "^18.0.0", "grunt-mocha-test": "^0.12.7", "grunt-npm": "0.0.2", "jasmine-core": "^2.3.4", diff --git a/requirejs.config.tpl.js b/requirejs.config.tpl.js index c2173ad60..d05eeeafd 100644 --- a/requirejs.config.tpl.js +++ b/requirejs.config.tpl.js @@ -1,16 +1,16 @@ -var allTestFiles = []; -var TEST_REGEXP = /(spec|test)\.js$/i; +var allTestFiles = [] +var TEST_REGEXP = /(spec|test)\.js$/i // Get a list of all the test files to include -Object.keys(window.__karma__.files).forEach(function(file) { +Object.keys(window.__karma__.files).forEach(function (file) { if (TEST_REGEXP.test(file)) { // Normalize paths to RequireJS module names. // If you require sub-dependencies of test files to be loaded as-is (requiring file extension) // then do not normalize the paths - var normalizedTestModule = file.replace(/^\/base\/|\.js$/g, ''); - allTestFiles.push(normalizedTestModule); + var normalizedTestModule = file.replace(/^\/base\/|\.js$/g, '') + allTestFiles.push(normalizedTestModule) } -}); +}) require.config({ // Karma serves files under /base, which is the basePath from your config file @@ -21,4 +21,4 @@ require.config({ // we have to kickoff jasmine, as it is asynchronous callback: window.__karma__.start -}); +}) diff --git a/test/e2e/steps/core_steps.js b/test/e2e/steps/core_steps.js index 6416a7a8c..999214f20 100644 --- a/test/e2e/steps/core_steps.js +++ b/test/e2e/steps/core_steps.js @@ -9,7 +9,7 @@ module.exports = function coreSteps () { this.World = require('../support/world').World require('../support/after_hooks').call(this) - var baseDir = fs.realpathSync(__dirname + '/../../..') + var baseDir = fs.realpathSync(path.join(__dirname, '/../../..')) var tmpDir = path.join(baseDir, 'tmp', 'sandbox') var tmpConfigFile = 'karma.conf.js' var cleansingNeeded = true diff --git a/test/unit/browser.spec.js b/test/unit/browser.spec.js index 6f7ef2762..c5692a1e0 100644 --- a/test/unit/browser.spec.js +++ b/test/unit/browser.spec.js @@ -46,7 +46,7 @@ describe('Browser', () => { browser.init() expect(collection.length).to.equal(1) - collection.forEach(browserInCollection => { + collection.forEach((browserInCollection) => { expect(browserInCollection).to.equal(browser) }) }) diff --git a/test/unit/browser_collection.spec.js b/test/unit/browser_collection.spec.js index 1737e1132..1434cfd04 100644 --- a/test/unit/browser_collection.spec.js +++ b/test/unit/browser_collection.spec.js @@ -74,14 +74,14 @@ describe('BrowserCollection', () => { beforeEach(() => { browsers = [new Browser(), new Browser(), new Browser()] - browsers.forEach(browser => { + browsers.forEach((browser) => { collection.add(browser) }) }) it('should set all browsers state to executing', () => { collection.setAllToExecuting() - browsers.forEach(browser => { + browsers.forEach((browser) => { expect(browser.isReady()).to.equal(false) expect(browser.state).to.equal(Browser.STATE_EXECUTING) }) @@ -100,7 +100,7 @@ describe('BrowserCollection', () => { beforeEach(() => { browsers = [new Browser(), new Browser(), new Browser()] - browsers.forEach(browser => { + browsers.forEach((browser) => { browser.state = Browser.STATE_READY collection.add(browser) }) @@ -237,7 +237,7 @@ describe('BrowserCollection', () => { browsers[1].lastResult.disconnected = true collection.clearResults() - browsers.forEach(browser => { + browsers.forEach((browser) => { expect(browser.lastResult.success).to.equal(0) expect(browser.lastResult.failed).to.equal(0) expect(browser.lastResult.skipped).to.equal(0) @@ -266,7 +266,7 @@ describe('BrowserCollection', () => { var browsers = [new Browser(1), new Browser(2), new Browser(3)] browsers.forEach(collection.add) - var mappedIds = collection.map(browser => browser.id) + var mappedIds = collection.map((browser) => browser.id) expect(mappedIds).to.deep.equal([1, 2, 3]) }) diff --git a/test/unit/cli.spec.js b/test/unit/cli.spec.js index 93dbf23ed..bf3b0dff2 100644 --- a/test/unit/cli.spec.js +++ b/test/unit/cli.spec.js @@ -23,7 +23,7 @@ describe('cli', () => { } } - var setCWD = cwd => { + var setCWD = (cwd) => { currentCwd = cwd fsMock._setCWD(cwd) } @@ -40,7 +40,7 @@ describe('cli', () => { mockery.console = {error: sinon.spy()} // load file under test - m = loadFile(__dirname + '/../../lib/cli.js', mockery, { + m = loadFile(path.join(__dirname, '/../../lib/cli.js'), mockery, { global: {}, console: mockery.console, process: mockery.process, diff --git a/test/unit/completion.spec.js b/test/unit/completion.spec.js index c6c04f70f..c39217bc6 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', (msg) => completion.push(msg)) completion = [] }) diff --git a/test/unit/config.spec.js b/test/unit/config.spec.js index 2c78ab2f9..c4e695bfd 100644 --- a/test/unit/config.spec.js +++ b/test/unit/config.spec.js @@ -8,9 +8,9 @@ describe('config', () => { var e var mocks - var resolveWinPath = p => helper.normalizeWinPath(path.resolve(p)) + var resolveWinPath = (p) => helper.normalizeWinPath(path.resolve(p)) - var normalizeConfigWithDefaults = cfg => { + var normalizeConfigWithDefaults = (cfg) => { if (!cfg.urlRoot) cfg.urlRoot = '' if (!cfg.files) cfg.files = [] if (!cfg.exclude) cfg.exclude = [] @@ -22,10 +22,10 @@ describe('config', () => { } // extract only pattern properties from list of pattern objects - var patternsFrom = list => list.map(pattern => pattern.pattern) + var patternsFrom = (list) => list.map((pattern) => pattern.pattern) var wrapCfg = function (cfg) { - return config => config.set(cfg) + return (config) => config.set(cfg) } beforeEach(() => { @@ -38,7 +38,7 @@ describe('config', () => { '/home/config4.js': wrapCfg({port: 123, autoWatch: true, basePath: '/abs/base'}), '/home/config6.js': wrapCfg({reporters: 'junit'}), '/home/config7.js': wrapCfg({browsers: ['Chrome', 'Firefox']}), - '/home/config8.js': config => config.set({ files: config.suite === 'e2e' ? ['tests/e2e.spec.js'] : ['tests/unit.spec.js'] }), + '/home/config8.js': (config) => config.set({ files: config.suite === 'e2e' ? ['tests/e2e.spec.js'] : ['tests/unit.spec.js'] }), '/conf/invalid.js': () => { throw new SyntaxError('Unexpected token =') }, '/conf/exclude.js': wrapCfg({exclude: ['one.js', 'sub/two.js']}), '/conf/absolute.js': wrapCfg({files: ['http://some.com', 'https://more.org/file.js']}), @@ -47,7 +47,7 @@ describe('config', () => { } // load file under test - m = loadFile(__dirname + '/../../lib/config.js', mocks, { + m = loadFile(path.join(__dirname, '/../../lib/config.js'), mocks, { global: {}, process: mocks.process, require (path) { @@ -360,7 +360,7 @@ describe('config', () => { describe('custom', () => { var di = require('di') - var forwardArgsFactory = args => args + var forwardArgsFactory = (args) => args var baseModule = { 'preprocessor:base': ['type', forwardArgsFactory], diff --git a/test/unit/emitter_wrapper.spec.js b/test/unit/emitter_wrapper.spec.js index b5caddbf9..1692ebac8 100644 --- a/test/unit/emitter_wrapper.spec.js +++ b/test/unit/emitter_wrapper.spec.js @@ -7,13 +7,13 @@ describe('emitter_wrapper', () => { beforeEach(() => { emitter = new EventEmitter() - emitter.aMethod = e => true + emitter.aMethod = (e) => true emitter.on('anEvent', emitter.aMethod) wrapped = new EmitterWrapper(emitter) }) describe('addListener', () => { - var aListener = e => true + var aListener = (e) => true it('should add a listener to the wrapped emitter', () => { wrapped.addListener('anEvent', aListener) @@ -26,7 +26,7 @@ describe('emitter_wrapper', () => { }) describe('removeAllListeners', () => { - var aListener = e => true + var aListener = (e) => true beforeEach(() => { wrapped.addListener('anEvent', aListener) @@ -43,7 +43,7 @@ describe('emitter_wrapper', () => { }) it('should remove only matching listeners when called with an event name', () => { - var anotherListener = e => true + var anotherListener = (e) => true wrapped.addListener('anotherEvent', anotherListener) wrapped.removeAllListeners('anEvent') expect(emitter.listeners('anEvent')).not.to.contain(aListener) diff --git a/test/unit/events.spec.js b/test/unit/events.spec.js index 6c254bdd0..e058e7b57 100644 --- a/test/unit/events.spec.js +++ b/test/unit/events.spec.js @@ -64,13 +64,13 @@ describe('events', () => { emitter.bind(object) }) - it('should resolve the promise once all listeners are done', done => { + it('should resolve the promise once all listeners are done', (done) => { var callbacks = [] var eventDone = sinon.spy() - emitter.on('a', d => d()) - emitter.on('a', d => callbacks.push(d)) - emitter.on('a', d => callbacks.push(d)) + emitter.on('a', (d) => d()) + emitter.on('a', (d) => callbacks.push(d)) + emitter.on('a', (d) => callbacks.push(d)) var promise = emitter.emitAsync('a') @@ -86,7 +86,7 @@ describe('events', () => { }) }) - it('should resolve asynchronously when no listener', done => { + it('should resolve asynchronously when no listener', (done) => { var spyDone = sinon.spy(done) emitter.emitAsync('whatever').then(spyDone) expect(spyDone).to.not.have.been.called diff --git a/test/unit/file-list.spec.js b/test/unit/file-list.spec.js index 5f0faa3ee..2f063391e 100644 --- a/test/unit/file-list.spec.js +++ b/test/unit/file-list.spec.js @@ -10,14 +10,14 @@ var from = require('core-js/library/fn/array/from') var config = require('../../lib/config') // create an array of pattern objects from given strings -var patterns = (...strings) => strings.map(str => new config.Pattern(str)) +var patterns = (...strings) => strings.map((str) => new config.Pattern(str)) function pathsFrom (files) { return _.pluck(from(files), 'path') } function findFile (path, files) { - return from(files).find(file => file.path === path) + return from(files).find((file) => file.path === path) } var PATTERN_LIST = { @@ -255,7 +255,7 @@ describe('FileList', () => { }) it('resolves patterns', () => { - return list.refresh().then(files => { + return list.refresh().then((files) => { expect(list.buckets.size).to.equal(2) var first = pathsFrom(list.buckets.get('/some/*.js')) @@ -267,7 +267,7 @@ describe('FileList', () => { }) it('cancels refreshs', () => { - var checkResult = files => { + var checkResult = (files) => { expect(_.pluck(files.served, 'path')).to.contain('/some/a.js', '/some/b.js', '/some/c.js') } @@ -290,7 +290,7 @@ describe('FileList', () => { }) it('sets the mtime for all files', () => { - return list.refresh().then(files => { + return list.refresh().then((files) => { var bucket = list.buckets.get('/some/*.js') var file1 = findFile('/some/a.js', bucket) @@ -304,7 +304,7 @@ describe('FileList', () => { it('sets the mtime for relative patterns', () => { list = new List(patterns('/some/world/../*.js', '*.txt'), [], emitter, preprocess) - return list.refresh().then(files => { + return list.refresh().then((files) => { var bucket = list.buckets.get('/some/world/../*.js') var file1 = findFile('/some/a.js', bucket) @@ -316,12 +316,12 @@ describe('FileList', () => { }) it('should sort files within buckets and keep order of patterns (buckets)', () => { - // /a.* => /a.txt [MATCH in *.txt as well] - // /some/*.js => /some/a.js, /some/b.js [/some/b.js EXCLUDED] - // *.txt => /c.txt, a.txt, b.txt [UNSORTED] + // /(a.* ) => /a.txt [MATCH in *.txt as well] + // /some/*.(js) => /some/a.js, /some/b.js [/some/b.js EXCLUDED] + // *.(txt ) => /c.txt, a.txt, b.txt [UNSORTED] list = new List(patterns('/a.*', '/some/*.js', '*.txt'), ['**/b.js'], emitter, preprocess) - return list.refresh().then(files => { + return list.refresh().then((files) => { expect(pathsFrom(files.served)).to.deep.equal([ '/a.txt', '/some/a.js', @@ -334,7 +334,7 @@ describe('FileList', () => { it('ingores excluded files', () => { list = new List(patterns('*.txt'), ['/a.*', '**/b.txt'], emitter, preprocess) - return list.refresh().then(files => { + return list.refresh().then((files) => { var bucket = pathsFrom(list.buckets.get('*.txt')) expect(bucket).to.contain('/c.txt') @@ -347,7 +347,7 @@ describe('FileList', () => { list = new List(patterns('http://some.com'), [], emitter, preprocess) return list.refresh() - .then(files => { + .then((files) => { var bucket = list.buckets.get('http://some.com') var file = findFile('http://some.com', bucket) @@ -357,7 +357,7 @@ describe('FileList', () => { }) it('preprocesses all files', () => { - return list.refresh().then(files => { + return list.refresh().then((files) => { expect(preprocess.callCount).to.be.eql(5) }) }) @@ -369,7 +369,7 @@ describe('FileList', () => { list = new List(patterns('/some/*.js'), [], emitter, preprocess) - return list.refresh().catch(err => { + return list.refresh().catch((err) => { expect(err.message).to.be.eql('failing') }) }) @@ -435,32 +435,32 @@ describe('FileList', () => { }) it('does not add excluded files', () => { - return list.refresh().then(before => { - return list.addFile('/secret/hello.txt').then(files => { + return list.refresh().then((before) => { + return list.addFile('/secret/hello.txt').then((files) => { expect(files.served).to.be.eql(before.served) }) }) }) it('does not add already existing files', () => { - return list.refresh().then(before => { - return list.addFile('/some/a.js').then(files => { + return list.refresh().then((before) => { + return list.addFile('/some/a.js').then((files) => { expect(files.served).to.be.eql(before.served) }) }) }) it('does not add unmatching files', () => { - return list.refresh().then(before => { - return list.addFile('/some/a.ex').then(files => { + return list.refresh().then((before) => { + return list.addFile('/some/a.ex').then((files) => { expect(files.served).to.be.eql(before.served) }) }) }) it('adds the file to the correct bucket', () => { - return list.refresh().then(before => { - return list.addFile('/some/d.js').then(files => { + return list.refresh().then((before) => { + return list.addFile('/some/d.js').then((files) => { expect(pathsFrom(files.served)).to.contain('/some/d.js') var bucket = list.buckets.get('/some/*.js') expect(pathsFrom(bucket)).to.contain('/some/d.js') @@ -503,7 +503,7 @@ describe('FileList', () => { list = new List(patterns('/a.*'), [], emitter, preprocess) return list.refresh().then(() => { - return list.addFile('/a.js').then(files => { + return list.addFile('/a.js').then((files) => { expect(findFile('/a.js', files.served).mtime).to.eql(new Date('2012-01-01')) }) }) @@ -512,7 +512,7 @@ describe('FileList', () => { it('preprocesses the added file', () => { // MATCH: /a.txt list = new List(patterns('/a.*'), [], emitter, preprocess) - return list.refresh().then(files => { + return list.refresh().then((files) => { preprocess.reset() return list.addFile('/a.js').then(() => { expect(preprocess).to.have.been.calledOnce @@ -554,11 +554,11 @@ describe('FileList', () => { var modified = sinon.stub() emitter.on('file_list_modified', modified) - return list.refresh().then(files => { + return list.refresh().then((files) => { mockFs._touchFile('/some/b.js', '2020-01-01') modified.reset() - return list.changeFile('/some/b.js').then(files => { + return list.changeFile('/some/b.js').then((files) => { expect(modified).to.have.been.calledOnce expect(findFile('/some/b.js', files.served).mtime).to.be.eql(new Date('2020-01-01')) }) @@ -572,7 +572,7 @@ describe('FileList', () => { var modified = sinon.stub() emitter.on('file_list_modified', modified) - return list.refresh().then(files => { + return list.refresh().then((files) => { mockFs._touchFile('/some/b.js', '2020-01-01') modified.reset() @@ -590,7 +590,7 @@ describe('FileList', () => { var modified = sinon.stub() emitter.on('file_list_modified', modified) - return list.refresh().then(files => { + return list.refresh().then((files) => { // not touching the file, stat will return still the same modified.reset() @@ -604,7 +604,7 @@ describe('FileList', () => { // MATCH: /some/a.js, /some/b.js list = new List(patterns('/some/*.js', '/a.*'), [], emitter, preprocess) - return list.refresh().then(files => { + return list.refresh().then((files) => { preprocess.reset() mockFs._touchFile('/some/a.js', '2020-01-01') return list.changeFile('/some/a.js').then(() => { @@ -648,10 +648,10 @@ describe('FileList', () => { var modified = sinon.stub() emitter.on('file_list_modified', modified) - return list.refresh().then(files => { + return list.refresh().then((files) => { modified.reset() return list.removeFile('/some/a.js') - }).then(files => { + }).then((files) => { expect(pathsFrom(files.served)).to.be.eql([ '/some/b.js', '/a.txt' @@ -664,7 +664,7 @@ describe('FileList', () => { // MATCH: /some/a.js, /some/b.js, /a.txt list = new List(patterns('/some/*.js', '/a.*'), [], emitter, preprocess) - return list.refresh().then(files => { + return list.refresh().then((files) => { modified.reset() return list.removeFile('/a.js').then(() => { expect(modified).to.not.have.been.called @@ -679,7 +679,7 @@ describe('FileList', () => { beforeEach(() => { patternList = PATTERN_LIST mg = MG - Promise.setScheduler(fn => fn()) + Promise.setScheduler((fn) => fn()) preprocess = sinon.spy((file, done) => process.nextTick(done)) emitter = new EventEmitter() @@ -709,14 +709,14 @@ describe('FileList', () => { afterEach(() => { clock.restore() - Promise.setScheduler(fn => process.nextTick(fn)) + Promise.setScheduler((fn) => process.nextTick(fn)) }) it('batches multiple changes within an interval', () => { // MATCH: /some/a.js, /some/b.js, /a.txt list = new List(patterns('/some/*.js', '/a.*'), [], emitter, preprocess, 100) - return list.refresh().then(files => { + return list.refresh().then((files) => { modified.reset() mockFs._touchFile('/some/b.js', '2020-01-01') list.changeFile('/some/b.js') @@ -740,10 +740,10 @@ 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', (done) => { list = new List(patterns('/a.*'), [], emitter, preprocess, 100) - return list.refresh().then(files => { + return list.refresh().then((files) => { preprocess.reset() modified.reset() diff --git a/test/unit/helper.spec.js b/test/unit/helper.spec.js index 7a10a81e4..ea6239ccc 100644 --- a/test/unit/helper.spec.js +++ b/test/unit/helper.spec.js @@ -1,9 +1,11 @@ +import path from 'path' + describe('helper', () => { var helper = require('../../lib/helper') describe('browserFullNameToShort', () => { // helper function - var expecting = name => expect(helper.browserFullNameToShort(name)) + var expecting = (name) => expect(helper.browserFullNameToShort(name)) it('should parse iOS', () => { expecting( @@ -217,15 +219,15 @@ describe('helper', () => { }) // load file under test - var m = loadFile(__dirname + '/../../lib/helper.js', {'graceful-fs': fs, lodash: require('lodash')}) + var m = loadFile(path.join(__dirname, '/../../lib/helper.js'), {'graceful-fs': fs, lodash: require('lodash')}) var mkdirIfNotExists = m.exports.mkdirIfNotExists - it('should not do anything, if dir already exists', done => { + it('should not do anything, if dir already exists', (done) => { mkdirIfNotExists('/home', done) }) - it('should create directory if it does not exist', done => { + it('should create directory if it does not exist', (done) => { mkdirIfNotExists('/home/new', () => { var stat = fs.statSync('/home/new') expect(stat).to.exist @@ -234,7 +236,7 @@ describe('helper', () => { }) }) - it('should create even parent directories if it does not exist', done => { + it('should create even parent directories if it does not exist', (done) => { mkdirIfNotExists('/home/new/parent/child', () => { var stat = fs.statSync('/home/new/parent/child') expect(stat).to.exist diff --git a/test/unit/init.spec.js b/test/unit/init.spec.js index 17ecb2237..d38884b24 100644 --- a/test/unit/init.spec.js +++ b/test/unit/init.spec.js @@ -4,13 +4,13 @@ describe('init', () => { var m = null beforeEach(() => { - m = loadFile(__dirname + '/../../lib/init.js', {glob: require('glob')}) + m = loadFile(path.join(__dirname, '/../../lib/init.js'), {glob: require('glob')}) sinon.stub(m, 'installPackage') }) describe('getBasePath', () => { // just for windows. - var replace = p => p.replace(/\//g, path.sep) + var replace = (p) => p.replace(/\//g, path.sep) it('should be empty if config file in cwd', () => { expect(m.getBasePath('some.conf', replace('/usr/local/whatever'))).to.equal('') @@ -45,7 +45,7 @@ describe('init', () => { }) describe('processAnswers', () => { - var answers = obj => { + var answers = (obj) => { obj = obj || {} obj.files = obj.files || [] obj.exclude = obj.exclude || [] @@ -97,7 +97,7 @@ describe('init', () => { var machine = formatter = null - var evaluateConfigCode = code => { + var evaluateConfigCode = (code) => { var sandbox = {module: {}} vm.runInNewContext(code, sandbox) var config = new DefaultKarmaConfig() @@ -110,8 +110,8 @@ describe('init', () => { formatter = new JavaScriptFormatter() }) - it('should generate working config', done => { - machine.process(m.questions, answers => { + it('should generate working config', (done) => { + machine.process(m.questions, (answers) => { var basePath = m.getBasePath('../karma.conf.js', path.normalize('/some/path')) var processedAnswers = m.processAnswers(answers, basePath) var generatedConfigCode = formatter.generateConfigFile(processedAnswers) @@ -154,8 +154,8 @@ describe('init', () => { machine.onLine('no') }) - it('should generate config for requirejs', done => { - machine.process(m.questions, answers => { + it('should generate config for requirejs', (done) => { + machine.process(m.questions, (answers) => { var basePath = m.getBasePath('../karma.conf.js', '/some/path') var processedAnswers = m.processAnswers(answers, basePath) var generatedConfigCode = formatter.generateConfigFile(processedAnswers) @@ -164,7 +164,7 @@ describe('init', () => { // expect correct configuration expect(config.frameworks).to.contain('requirejs') expect(config.files).to.contain('test/main.js') - config.files.slice(1).forEach(pattern => { + config.files.slice(1).forEach((pattern) => { expect(pattern.included).to.equal(false) }) @@ -202,8 +202,8 @@ describe('init', () => { machine.onLine('yes') }) - it('should generate the test-main for requirejs', done => { - machine.process(m.questions, answers => { + it('should generate the test-main for requirejs', (done) => { + machine.process(m.questions, (answers) => { var basePath = m.getBasePath('../karma.conf.js', '/some/path') var processedAnswers = m.processAnswers(answers, basePath, 'test-main.js') var generatedConfigCode = formatter.generateConfigFile(processedAnswers) @@ -215,7 +215,7 @@ describe('init', () => { // expect correct configuration expect(config.frameworks).to.contain('requirejs') - config.files.slice(1).forEach(pattern => { + config.files.slice(1).forEach((pattern) => { expect(pattern.included).to.equal(false) }) @@ -249,8 +249,8 @@ describe('init', () => { machine.onLine('yes') }) - it('should add coffee preprocessor', done => { - machine.process(m.questions, answers => { + it('should add coffee preprocessor', (done) => { + machine.process(m.questions, (answers) => { var basePath = m.getBasePath('karma.conf.js', '/cwd') var processedAnswers = m.processAnswers(answers, basePath) var generatedConfigCode = formatter.generateConfigFile(processedAnswers) diff --git a/test/unit/init/state_machine.spec.js b/test/unit/init/state_machine.spec.js index a4142d5b8..f2ab7ad0e 100644 --- a/test/unit/init/state_machine.spec.js +++ b/test/unit/init/state_machine.spec.js @@ -27,7 +27,7 @@ describe('init/StateMachine', () => { {id: 'other'} ] - done = sinon.spy(answers => { + done = sinon.spy((answers) => { expect(answers.framework).to.equal('jasmine') expect(answers.other).to.equal('abc') }) @@ -43,7 +43,7 @@ describe('init/StateMachine', () => { {id: 'browsers', multiple: true} ] - done = sinon.spy(answers => { + done = sinon.spy((answers) => { expect(answers.browsers).to.deep.equal(['Chrome', 'Safari']) }) @@ -59,7 +59,7 @@ describe('init/StateMachine', () => { {id: 'browsers', multiple: true} ] - done = sinon.spy(answers => { + done = sinon.spy((answers) => { expect(answers.browsers).to.deep.equal(['Chrome']) }) @@ -74,7 +74,7 @@ describe('init/StateMachine', () => { {id: 'empty', multiple: true} ] - done = sinon.spy(answers => { + done = sinon.spy((answers) => { expect(answers.empty).to.deep.equal([]) }) @@ -97,14 +97,14 @@ describe('init/StateMachine', () => { }) it('should allow conditional answers', () => { - var ifTrue = sinon.spy(answers => { + var ifTrue = sinon.spy((answers) => { return answers.first === 'true' }) - var ifFalse = sinon.spy(answers => { + var ifFalse = sinon.spy((answers) => { return answers.first === 'false' }) - done = sinon.spy(answers => { + done = sinon.spy((answers) => { expect(answers.first).to.equal('true') expect(answers.onlyIfTrue).to.equal('something') expect(answers.onlyIfFalse).to.not.exist @@ -124,7 +124,7 @@ describe('init/StateMachine', () => { }) it('should parse booleans', () => { - done = sinon.spy(answers => { + done = sinon.spy((answers) => { expect(answers.yes).to.equal(true) expect(answers.no).to.equal(false) }) @@ -142,7 +142,7 @@ describe('init/StateMachine', () => { }) it('should parse booleans before validation', () => { - var validator = sinon.spy(value => { + var validator = sinon.spy((value) => { expect(typeof value).to.equal('boolean') }) diff --git a/test/unit/launcher.spec.js b/test/unit/launcher.spec.js index c81ddef4b..109664d9c 100644 --- a/test/unit/launcher.spec.js +++ b/test/unit/launcher.spec.js @@ -6,7 +6,7 @@ import createMockTimer from './mocks/timer' // promise mock var stubPromise = (obj, method, stubAction) => { - var promise = new Promise(resolve => { + var promise = new Promise((resolve) => { obj[method].resolve = resolve }) @@ -54,11 +54,11 @@ describe('launcher', () => { } before(() => { - Promise.setScheduler(fn => fn()) + Promise.setScheduler((fn) => fn()) }) after(() => { - Promise.setScheduler(fn => process.nextTick(fn)) + Promise.setScheduler((fn) => process.nextTick(fn)) }) beforeEach(() => { @@ -147,7 +147,7 @@ describe('launcher', () => { }) describe('kill', () => { - it('should kill browser with given id', done => { + it('should kill browser with given id', (done) => { l.launch(['Fake'], 'http:', 'localhost', 1234, '/', 1) var browser = FakeBrowser._instances.pop() @@ -157,7 +157,7 @@ describe('launcher', () => { browser.forceKill.resolve() }) - it('should return false if browser does not exist, but still resolve the callback', done => { + it('should return false if browser does not exist, but still resolve the callback', (done) => { l.launch(['Fake'], 'http:', 'localhost', 1234, '/', 1) var browser = FakeBrowser._instances.pop() @@ -166,7 +166,7 @@ describe('launcher', () => { expect(browser.forceKill).not.to.have.been.called }) - it('should not require a callback', done => { + it('should not require a callback', (done) => { l.launch(['Fake'], 'http:', 'localhost', 1234, '/', 1) FakeBrowser._instances.pop() @@ -214,7 +214,7 @@ describe('launcher', () => { }) }) - it('should call callback even if no browsers lanunched', done => { + it('should call callback even if no browsers lanunched', (done) => { l.killAll(done) }) }) @@ -234,7 +234,7 @@ describe('launcher', () => { }) describe('onExit', () => { - it('should kill all browsers', done => { + it('should kill all browsers', (done) => { l.launch(['Fake', 'Fake'], 'http:', 'localhost', 1234, '/', 1) emitter.emitAsync('exit').then(done) diff --git a/test/unit/launchers/base.spec.js b/test/unit/launchers/base.spec.js index 427b15b53..63d12a76c 100644 --- a/test/unit/launchers/base.spec.js +++ b/test/unit/launchers/base.spec.js @@ -31,7 +31,7 @@ describe('launchers/base.js', () => { }) describe('restart', () => { - it('should kill running browser and start with previous url', done => { + it('should kill running browser and start with previous url', (done) => { var spyOnStart = sinon.spy() var spyOnKill = sinon.spy() launcher.on('start', spyOnStart) @@ -54,7 +54,7 @@ describe('launchers/base.js', () => { }) }) - it('should start when already finished (crashed)', done => { + it('should start when already finished (crashed)', (done) => { var spyOnStart = sinon.spy() var spyOnKill = sinon.spy() var spyOnDone = sinon.spy() @@ -80,7 +80,7 @@ describe('launchers/base.js', () => { }) }) - it('should not restart when being force killed', done => { + it('should not restart when being force killed', (done) => { var spyOnStart = sinon.spy() var spyOnKill = sinon.spy() launcher.on('start', spyOnStart) @@ -105,7 +105,7 @@ describe('launchers/base.js', () => { }) describe('kill', () => { - it('should manage state', done => { + it('should manage state', (done) => { var onceKilled = launcher.kill() expect(launcher.state).to.equal(launcher.STATE_BEING_KILLED) @@ -115,7 +115,7 @@ describe('launchers/base.js', () => { }) }) - it('should fire "kill" and wait for all listeners to finish', done => { + it('should fire "kill" and wait for all listeners to finish', (done) => { var spyOnKill1 = sinon.spy() var spyOnKill2 = sinon.spy() var spyKillDone = sinon.spy(done) @@ -135,7 +135,7 @@ describe('launchers/base.js', () => { spyOnKill2.callArg(0) }) // the second listener is done - it('should not fire "kill" if already killed', done => { + it('should not fire "kill" if already killed', (done) => { var spyOnKill = sinon.spy() launcher.on('kill', spyOnKill) @@ -151,7 +151,7 @@ describe('launchers/base.js', () => { spyOnKill.callArg(0) }) - it('should not fire "kill" if already being killed, but wait for all listeners', done => { + it('should not fire "kill" if already being killed, but wait for all listeners', (done) => { var spyOnKill = sinon.spy() launcher.on('kill', spyOnKill) @@ -182,8 +182,8 @@ describe('launchers/base.js', () => { firstKilling.done(() => secondKilling.done(() => done())) }) - it('should not kill already crashed browser', done => { - var spyOnKill = sinon.spy(killDone => killDone()) + it('should not kill already crashed browser', (done) => { + var spyOnKill = sinon.spy((killDone) => killDone()) launcher.on('kill', spyOnKill) launcher._done('crash') @@ -195,7 +195,7 @@ describe('launchers/base.js', () => { }) describe('forceKill', () => { - it('should cancel restart', done => { + it('should cancel restart', (done) => { var spyOnStart = sinon.spy() launcher.on('start', spyOnStart) @@ -210,11 +210,11 @@ describe('launchers/base.js', () => { }) }) - it('should not fire "browser_process_failure" even if browser crashes', done => { + it('should not fire "browser_process_failure" even if browser crashes', (done) => { var spyOnBrowserProcessFailure = sinon.spy() emitter.on('browser_process_failure', spyOnBrowserProcessFailure) - launcher.on('kill', killDone => { + launcher.on('kill', (killDone) => { _.defer(() => { launcher._done('crashed') killDone() diff --git a/test/unit/launchers/capture_timeout.spec.js b/test/unit/launchers/capture_timeout.spec.js index 6b5c41a99..636dfee1d 100644 --- a/test/unit/launchers/capture_timeout.spec.js +++ b/test/unit/launchers/capture_timeout.spec.js @@ -38,11 +38,11 @@ describe('launchers/capture_timeout.js', () => { expect(launcher.kill).not.to.have.been.called }) - it('should clear timeout between restarts', done => { + it('should clear timeout between restarts', (done) => { CaptureTimeoutLauncher.call(launcher, timer, 10) // simulate process finished - launcher.on('kill', onKillDone => { + launcher.on('kill', (onKillDone) => { launcher._done() onKillDone() }) diff --git a/test/unit/launchers/process.spec.js b/test/unit/launchers/process.spec.js index 00a16e137..d0502a8b5 100644 --- a/test/unit/launchers/process.spec.js +++ b/test/unit/launchers/process.spec.js @@ -31,7 +31,7 @@ describe('launchers/process.js', () => { mockSpawn._processes = [] mockTempDir = { - getPath: suffix => `/temp${suffix}`, + getPath: (suffix) => `/temp${suffix}`, create: sinon.spy(), remove: sinon.spy() } diff --git a/test/unit/logger.spec.js b/test/unit/logger.spec.js index a4516b96e..873ba3c5a 100644 --- a/test/unit/logger.spec.js +++ b/test/unit/logger.spec.js @@ -1,10 +1,11 @@ import {loadFile} from 'mocks' +import path from 'path' describe('logger', () => { var m beforeEach(() => { - m = loadFile(__dirname + '/../../lib/logger.js') + m = loadFile(path.join(__dirname, '/../../lib/logger.js')) }) describe('setup', () => { diff --git a/test/unit/middleware/proxy.spec.js b/test/unit/middleware/proxy.spec.js index f04eba800..a3eaad4b5 100644 --- a/test/unit/middleware/proxy.spec.js +++ b/test/unit/middleware/proxy.spec.js @@ -1,3 +1,4 @@ +import path from 'path' var httpMock = require('mocks').http var loadFile = require('mocks').loadFile @@ -7,7 +8,7 @@ describe('middleware.proxy', () => { var nextSpy var type - var m = loadFile(__dirname + '/../../../lib/middleware/proxy.js') + var m = loadFile(path.join(__dirname, '/../../../lib/middleware/proxy.js')) var mockProxies = [{ path: '/proxy', diff --git a/test/unit/middleware/runner.spec.js b/test/unit/middleware/runner.spec.js index d925bc5b7..8e7228aba 100644 --- a/test/unit/middleware/runner.spec.js +++ b/test/unit/middleware/runner.spec.js @@ -21,18 +21,18 @@ describe('middleware.runner', () => { var fileListMock before(() => { - Promise.setScheduler(fn => fn()) + Promise.setScheduler((fn) => fn()) }) after(() => { - Promise.setScheduler(fn => process.nextTick(fn)) + Promise.setScheduler((fn) => process.nextTick(fn)) }) beforeEach(() => { mockReporter = { adapters: [], write (msg) { - return this.adapters.forEach(adapter => adapter(msg)) + return this.adapters.forEach((adapter) => adapter(msg)) } } @@ -204,9 +204,9 @@ describe('middleware.runner', () => { capturedBrowsers.add(new Browser()) sinon.stub(capturedBrowsers, 'areAllReady', () => true) - var resolve = null - var fileListPromise = new Promise((_resolve, _reject) => { - resolve = _resolve + var res = null + var fileListPromise = new Promise((resolve, reject) => { + res = resolve }) sinon.stub(fileListMock, 'refresh').returns(fileListPromise) sinon.stub(executor, 'schedule') @@ -219,7 +219,7 @@ describe('middleware.runner', () => { expect(executor.schedule).to.not.have.been.called // Now try resolving the promise - resolve() + res() setTimeout(() => { expect(executor.schedule).to.have.been.called done() diff --git a/test/unit/mocha-globals.js b/test/unit/mocha-globals.js index 5514c54f5..089961ad7 100644 --- a/test/unit/mocha-globals.js +++ b/test/unit/mocha-globals.js @@ -32,18 +32,18 @@ chai.use((chai, utils) => { var response = utils.flag(this, 'object') this.assert(response._status === expectedStatus, - `expected response status '#{response._status}' to be '#{expectedStatus}'`) + `expected response status '${response._status}' to be '${expectedStatus}'`) this.assert(response._body === expectedBody, - `expected response body '#{response._body}' to be '#{expectedBody}'`) + `expected response body '${response._body}' to be '${expectedBody}'`) }) chai.Assertion.addMethod('beNotServed', function () { var response = utils.flag(this, 'object') this.assert(response._status === null, - `expected response status to not be set, it was '#{response._status}'`) + `expected response status to not be set, it was '${response._status}'`) this.assert(response._body === null, - `expected response body to not be set, it was '#{response._body}'`) + `expected response body to not be set, it was '${response._body}'`) }) }) @@ -55,7 +55,7 @@ var nextTickCallback = () => { if (nextTickQueue.length) process.nextTick(nextTickCallback) } -global.scheduleNextTick = action => { +global.scheduleNextTick = (action) => { nextTickQueue.push(action) if (nextTickQueue.length === 1) process.nextTick(nextTickCallback) @@ -66,12 +66,12 @@ var nextCallback = () => { nextQueue.shift()() } -global.scheduleNextTick = action => { +global.scheduleNextTick = (action) => { nextTickQueue.push(action) if (nextTickQueue.length === 1) process.nextTick(nextTickCallback) } -global.scheduleNext = action => { +global.scheduleNext = (action) => { nextQueue.push(action) } diff --git a/test/unit/preprocessor.spec.js b/test/unit/preprocessor.spec.js index c0ba52d40..59242f4c3 100644 --- a/test/unit/preprocessor.spec.js +++ b/test/unit/preprocessor.spec.js @@ -1,5 +1,6 @@ import mocks from 'mocks' import di from 'di' +import path from 'path' describe('preprocessor', () => { var pp @@ -28,10 +29,10 @@ describe('preprocessor', () => { minimatch: require('minimatch') } - m = mocks.loadFile(__dirname + '/../../lib/preprocessor.js', mocks_) + m = mocks.loadFile(path.join(__dirname, '/../../lib/preprocessor.js'), mocks_) }) - it('should preprocess matching file', done => { + it('should preprocess matching file', (done) => { var fakePreprocessor = sinon.spy((content, file, done) => { file.path = file.path + '-preprocessed' done(null, 'new-content') @@ -50,7 +51,7 @@ describe('preprocessor', () => { }) }) - it('should match directories starting with a dot', done => { + it('should match directories starting with a dot', (done) => { var fakePreprocessor = sinon.spy((content, file, done) => { file.path = file.path + '-preprocessed' done(null, 'new-content') @@ -69,7 +70,7 @@ describe('preprocessor', () => { }) }) - it('should check patterns after creation when invoked', done => { + it('should check patterns after creation when invoked', (done) => { var fakePreprocessor = sinon.spy((content, file, done) => { file.path = file.path + '-preprocessed' done(null, 'new-content') @@ -91,7 +92,7 @@ describe('preprocessor', () => { }) }) - it('should ignore not matching file', done => { + it('should ignore not matching file', (done) => { var fakePreprocessor = sinon.spy((content, file, done) => { done(null, '') }) @@ -107,7 +108,7 @@ describe('preprocessor', () => { }) }) - it('should apply all preprocessors', done => { + it('should apply all preprocessors', (done) => { var fakePreprocessor1 = sinon.spy((content, file, done) => { file.path = file.path + '-p1' done(null, content + '-c1') @@ -136,7 +137,7 @@ describe('preprocessor', () => { }) }) - it('should compute SHA', done => { + it('should compute SHA', (done) => { pp = m.createPreprocessor({}, null, new di.Injector([])) var file = {originalPath: '/some/a.js', path: 'path'} @@ -158,7 +159,7 @@ describe('preprocessor', () => { }) }) - it('should compute SHA from content returned by a processor', done => { + it('should compute SHA from content returned by a processor', (done) => { var fakePreprocessor = sinon.spy((content, file, done) => { done(null, content + '-processed') }) @@ -184,7 +185,7 @@ describe('preprocessor', () => { }) }) - it('should return error if any preprocessor fails', done => { + it('should return error if any preprocessor fails', (done) => { var failingPreprocessor = sinon.spy((content, file, done) => { done(new Error('Some error'), null) }) @@ -197,13 +198,13 @@ describe('preprocessor', () => { var file = {originalPath: '/some/a.js', path: 'path'} - pp(file, err => { + pp(file, (err) => { expect(err).to.exist done() }) }) - it('should stop preprocessing after an error', done => { + it('should stop preprocessing after an error', (done) => { var failingPreprocessor = sinon.spy((content, file, done) => { done(new Error('Some error'), null) }) @@ -227,7 +228,7 @@ describe('preprocessor', () => { }) }) - it('should not preprocess binary files', done => { + it('should not preprocess binary files', (done) => { var fakePreprocessor = sinon.spy((content, file, done) => { done(null, content) }) @@ -240,7 +241,7 @@ describe('preprocessor', () => { var file = {originalPath: '/some/photo.png', path: 'path'} - pp(file, err => { + pp(file, (err) => { if (err) throw err expect(fakePreprocessor).not.to.have.been.called @@ -262,7 +263,7 @@ describe('preprocessor', () => { var file = {originalPath: '/some/CAM_PHOTO.JPG', path: 'path'} - pp(file, err => { + pp(file, (err) => { if (err) throw err expect(fakePreprocessor).not.to.have.been.called diff --git a/test/unit/reporter.spec.js b/test/unit/reporter.spec.js index 596d4a0f8..e40d8298c 100644 --- a/test/unit/reporter.spec.js +++ b/test/unit/reporter.spec.js @@ -1,13 +1,14 @@ import {EventEmitter} from 'events' import File from '../../lib/file' import {loadFile} from 'mocks' +import path from 'path' var _ = require('../../lib/helper')._ describe('reporter', () => { var m beforeEach(() => { - m = loadFile(__dirname + '/../../lib/reporter.js') + m = loadFile(path.join(__dirname, '/../../lib/reporter.js')) }) // ============================================================================== @@ -103,7 +104,7 @@ describe('reporter', () => { MockSourceMapConsumer.GREATEST_LOWER_BOUND = 1 MockSourceMapConsumer.LEAST_UPPER_BOUND = 2 - it('should rewrite stack traces', done => { + it('should rewrite stack traces', (done) => { formatError = m.createErrorFormatter('/some/base', emitter, MockSourceMapConsumer) var servedFiles = [new File('/some/base/a.js'), new File('/some/base/b.js')] servedFiles[0].sourceMap = {content: 'SOURCE MAP a.js'} @@ -118,7 +119,7 @@ describe('reporter', () => { }) }) - it('should rewrite stack traces to the first column when no column is given', done => { + it('should rewrite stack traces to the first column when no column is given', (done) => { formatError = m.createErrorFormatter('/some/base', emitter, MockSourceMapConsumer) var servedFiles = [new File('/some/base/a.js'), new File('/some/base/b.js')] servedFiles[0].sourceMap = {content: 'SOURCE MAP a.js'} @@ -133,7 +134,7 @@ describe('reporter', () => { }) }) - it('should rewrite relative url stack traces', done => { + it('should rewrite relative url stack traces', (done) => { formatError = m.createErrorFormatter('/some/base', emitter, MockSourceMapConsumer) var servedFiles = [new File('/some/base/a.js'), new File('/some/base/b.js')] servedFiles[0].sourceMap = {content: 'SOURCE MAP a.js'} @@ -148,7 +149,7 @@ describe('reporter', () => { }) }) - it('should fall back to non-source-map format if originalPositionFor throws', done => { + it('should fall back to non-source-map format if originalPositionFor throws', (done) => { formatError = m.createErrorFormatter('/some/base', emitter, MockSourceMapConsumer) var servedFiles = [new File('/some/base/a.js'), new File('/some/base/b.js')] servedFiles[0].sourceMap = {content: 'SOURCE MAP a.js'} @@ -163,7 +164,7 @@ describe('reporter', () => { }) }) - it('should not try to use source maps when no line is given', done => { + it('should not try to use source maps when no line is given', (done) => { formatError = m.createErrorFormatter('/some/base', emitter, MockSourceMapConsumer) var servedFiles = [new File('/some/base/a.js'), new File('/some/base/b.js')] servedFiles[0].sourceMap = {content: 'SOURCE MAP a.js'} @@ -189,7 +190,7 @@ describe('reporter', () => { servedFiles[0].sourceMap = {content: 'SOURCE MAP b.js'} }) - it('should correct rewrite stack traces without sha', done => { + it('should correct rewrite stack traces without sha', (done) => { emitter.emit('file_list_modified', {served: servedFiles}) _.defer(() => { @@ -199,7 +200,7 @@ describe('reporter', () => { }) }) - it('should correct rewrite stack traces with sha', done => { + it('should correct rewrite stack traces with sha', (done) => { emitter.emit('file_list_modified', {served: servedFiles}) _.defer(() => { diff --git a/test/unit/reporters/base.spec.js b/test/unit/reporters/base.spec.js index 0eee0cd20..5c5b16496 100644 --- a/test/unit/reporters/base.spec.js +++ b/test/unit/reporters/base.spec.js @@ -1,12 +1,11 @@ -// ============================================================================== -// lib/reporters/Base.js module -// ============================================================================== +import path from 'path' + describe('reporter', function () { var loadFile = require('mocks').loadFile var m = null beforeEach(function () { - m = loadFile(__dirname + '/../../../lib/reporters/base.js') + m = loadFile(path.join(__dirname, '/../../../lib/reporters/base.js')) return m }) diff --git a/test/unit/runner.spec.js b/test/unit/runner.spec.js index 2f21d50ba..68d45491e 100644 --- a/test/unit/runner.spec.js +++ b/test/unit/runner.spec.js @@ -1,11 +1,12 @@ import {loadFile} from 'mocks' import constant from '../../lib/constants' +import path from 'path' describe('runner', () => { var m beforeEach(() => { - m = loadFile(__dirname + '/../../lib/runner.js') + m = loadFile(path.join(__dirname, '/../../lib/runner.js')) }) describe('parseExitCode', () => { diff --git a/test/unit/watcher.spec.js b/test/unit/watcher.spec.js index 5fec31915..fb07f8d7e 100644 --- a/test/unit/watcher.spec.js +++ b/test/unit/watcher.spec.js @@ -8,7 +8,7 @@ describe('watcher', () => { beforeEach(() => { var mocks_ = {chokidar: mocks.chokidar} - m = mocks.loadFile(__dirname + '/../../lib/watcher.js', mocks_) + m = mocks.loadFile(path.join(__dirname, '/../../lib/watcher.js'), mocks_) }) describe('baseDirFromPattern', () => { diff --git a/test/unit/web-server.spec.js b/test/unit/web-server.spec.js index 17327c5de..d60f45bfb 100644 --- a/test/unit/web-server.spec.js +++ b/test/unit/web-server.spec.js @@ -5,6 +5,7 @@ import di from 'di' import mocks from 'mocks' import fs from 'fs' import mime from 'mime' +import path from 'path' describe('web-server', () => { var server @@ -30,8 +31,7 @@ describe('web-server', () => { // NOTE(vojta): only loading once, to speed things up // this relies on the fact that none of these tests mutate fs - var m = mocks.loadFile(__dirname + '/../../lib/web-server.js', _mocks, _globals) - + var m = mocks.loadFile(path.join(__dirname, '/../../lib/web-server.js'), _mocks, _globals) var customFileHandlers = server = emitter = null var middlewareActive = false var servedFiles = (files) => { @@ -167,8 +167,8 @@ describe('web-server', () => { describe('https', () => { beforeEach(() => { var credentials = { - key: fs.readFileSync(__dirname + '/certificates/server.key'), - cert: fs.readFileSync(__dirname + '/certificates/server.crt') + key: fs.readFileSync(path.join(__dirname, '/certificates/server.key')), + cert: fs.readFileSync(path.join(__dirname, '/certificates/server.crt')) } customFileHandlers = []