2016-10-18 9 views
2

カルマテストを組み込みようとしています。私は1.5、webpackとgulpを使っています。 I karma startとき、私はターミナルで次を得る:カルマ/ジャスミン/ファントム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` 

私はこのエラーを取得しています理由として何かアドバイスをいただければ幸いです。私はPhantomがes6を受け入れていないのでそれがあると仮定しています。私はkarma-es6-shimと他のいくつかのものを成功せずに試しました。
karma.conf.js WebPACKの設定ファイルで

`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 
    }); 
};` 
+0

はあなたの問題を解決しました問題を解決し、希望

module: { loaders: [ { test: /\.jsx?$/, loader: 'babel', exclude: /node_modules/, } ] } 

追加:
はここに私のファイルはありますか?ウェブパックの設定には何がありますか? –

+0

こんにちはルーク、はい、私たちはkarma.configファイルの完全な変更を行い、単にカルマのためのインデックスを含んでいました。 3週間ほどかかりましたが、私はカルマで正式にテストしています! –

+1

これらの設定を共有するのはどうですか? @KateS – Mouneer

答えて

1

これは

関連する問題