Reputation: 318
I am attempting to incorporate karma testing. I am using angular 1.5, webpack and gulp. When I karma start
I get the following in the terminal:
`18 10 2016 13:52:03.082:WARN [karma]: No captured browser, open http://localhost:9876/
18 10 2016 13:52:03.100:WARN [karma]: Port 9876 in use
18 10 2016 13:52:03.101:INFO [karma]: Karma v1.1.2 server started at http://localhost:9877/
18 10 2016 13:52:03.101:INFO [launcher]: Launching browser PhantomJS with unlimited concurrency
18 10 2016 13:52:03.125:INFO [launcher]: Starting browser PhantomJS
18 10 2016 13:52:06.629:WARN [karma]: No captured browser, open http://localhost:9877/
18 10 2016 13:52:06.649:INFO [PhantomJS 2.1.1 (Mac OS X 0.0.0)]: Connected on socket /#EcTUgwnkFnvZHyN0AAAA with id 14262338
PhantomJS 2.1.1 (Mac OS X 0.0.0) ERROR
SyntaxError: Use of reserved word 'import'
at Project/src/app/index.js:14`
I would appreciate any advice as to why I am getting this error. I am assuming it is because Phantom does not accept es6. I've tried the karma-es6-shim and a few other things without success.
Here are my files:
karma.conf.js
`var webpackConfig = require('./webpack.config');
module.exports = function(config) {
config.set({
// base path that will be used to resolve all patterns (eg. files, exclude)
basePath: '../',
// frameworks to use
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
frameworks: ['jasmine'],`
// list of files / patterns to load in the browser
files: [
{ pattern: './Project/node_modules/jquery/dist/jquery.js'},
{ pattern: './Project/node_modules/angular/angular.js' },
{ pattern: './Project/node_modules/angular-mocks/angular-mocks.js'},
{ pattern: './Project/src/app/index.js'},
{ pattern: './Project/src/app/Test/**/*.spec.js', watched: false}
],
// list of files to exclude
exclude: [
'lambda/*/*.js'
],
// preprocess matching files before serving them to the browser
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors: {
'./src/app/**/*.js': ['babel'],
'./src/app/**/index.js': ['webpack'],
'./src/app/Test/**/index.js': ['webpack'],
'./src/app/Test/**/.js': ['babel']
},
webpack: webpackConfig('module'),
webpackMiddleware: {
noInfo: true
},
// test results reporter to use
// possible values: 'dots', 'progress'
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
reporters: ['progress'],
// web server port
//port: 9876,
// enable / disable colors in the output (reporters and logs)
colors: true,
// level of logging
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
logLevel: config.LOG_INFO.DEBUG,
// enable / disable watching file and executing tests whenever any file changes
autoWatch: true,
// start these browsers
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
browsers: ['PhantomJS'],
// Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits
singleRun: false,
plugins: [
require('karma-babel-preprocessor'),
require('karma-jasmine'),
require('karma-webpack'),
// require('karma-chrome-launcher')
require('karma-phantomjs-launcher')
],
// Concurrency level
// how many browser should be started simultaneous
concurrency: Infinity
});
};`
Upvotes: 3
Views: 3802
Reputation: 21
In webpack config file add
module: {
loaders: [
{
test: /\.jsx?$/,
loader: 'babel',
exclude: /node_modules/,
}
]
}
hope this solves the issue
Upvotes: 2