2
我試圖合併業力測試。我正在使用angular 1.5,webpack和gulp。當我我karma start
獲得在終端執行以下操作:Karma/Jasmine/Phantom JS測試 - SyntaxError:使用保留字'import'
`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`
我將不勝感激任何意見,爲什麼我收到此錯誤。我假設這是因爲幻影不接受es6。我已經嘗試了karma-es6-shim和其他一些沒有成功的事情。
這裏是我的文件:
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
});
};`
你解決你的問題,這個問題?你有什麼在你的webpack配置? –
嗨盧克,是的,我們對karma.config文件做了一個完整的更改,並且包含一個僅用於業力的索引。花了大約三週時間,但我正式在Karma進行測試! –
分享這些配置怎麼樣? @KateS – Mouneer