Karma test run invalid config file

karma
nodejs

#1

my karma test config is like this

'use strict'

let webpack = require('webpack')
let	path = require('path')
let dir = require('directory-scan')
let myModules = dir.get('./','dist')

module.exports = function (config) {
	config.set({
		basePath: '',
		frameworks: ['jasmine'],
		files: [
			'./spec/*.spec.js'
		],
		preprocessors: {
			'./spec/*.spec.js': ['webpack']
		},
		webpack: {
			module: {
				loaders: [
					{
						test: /\.(js|jsx)$/,
						loader: 'babel-loader',
						exclude: /node_modules/,
						query: {
							presets: ['es2015', 'react']
						}
					},
					{
						test: /\.(css|scss)$/,
						loader: 'null-loader'
					},
					{
						test: /\.(woff|woff2|eot|ttf)$/i,
						loader: 'null-loader'
					},
					{
						test: /\.(jpe?g|gif|png|svg)$/i,
						loader: 'null-loader'
					},
					{
						test: /vendor\/.+\.(jsx|js)$/,
						loader: 'imports?jQuery=jquery,$=jquery,this=>window'
					}
				]
			},
			resolve: {
				modules: [...myModules, 'node_modules'],
			},
			externals: {
				'jsdom': 'window',
				'cheerio': 'window',
				'react/addons': true,
				'react/lib/ExecutionEnvironment': true,
				'react/lib/ReactContext': true
			},
			node: {
				fs: 'empty' // this fixes 'can not resolve module fs'
			}
		},
		webpackMiddleware: {
			noInfo: true
		},
		plugins: [
			'karma-webpack',
			'karma-jasmine',
			'karma-phantomjs-launcher',
			'karma-chrome-launcher',
			'karma-verbose-reporter',
		],
		reporters: ['verbose','progress'],
		port: 9876,
		colors: true,
		logLevel: config.LOG_INFO,
		autoWatch: true,
		browsers: ['Chrome'],
		singleRun: false
	})
}

problem: I got the following error when run test

    > that-i-like@1.0.0 test /home/ubuntu/thatilike-frontend
    > karma start karma.conf.js
    
    03 03 2017 06:00:10.563:ERROR [config]: Invalid config file!
SyntaxError: Unexpected token ...
    at exports.runInThisContext (vm.js:53:16)
    at Module._compile (module.js:374:25)
    at Object.Module._extensions..js (module.js:417:10)
    at Module.load (module.js:344:32)
    at Function.Module._load (module.js:301:12)
    at Module.require (module.js:354:17)
    at require (internal/module.js:12:17)
    at Object.parseConfig (/home/ubuntu/thatilike-frontend/node_modules/karma/lib/config.js:363:22)
    at new Server (/home/ubuntu/thatilike-frontend/node_modules/karma/lib/server.js:56:20)
    at Object.exports.run (/home/ubuntu/thatilike-frontend/node_modules/karma/lib/cli.js:280:7)
    at Object.<anonymous> (/home/ubuntu/thatilike-frontend/node_modules/karma/bin/karma:3:23)
    at Module._compile (module.js:410:26)
    at Object.Module._extensions..js (module.js:417:10)
    at Module.load (module.js:344:32)
    at Function.Module._load (module.js:301:12)
    at Function.Module.runMain (module.js:442:10)
npm ERR! Test failed.  See above for more details.

What does this really mean? Is there solution?


#2

I know why, I used spread operator ... in my config, circleci doesn’t understand that.


#3

Thank you for following up @craigcosmo!


#4