2017-07-17 9 views
1

私はES6でangularJSを使ってプロジェクトを構築しています。karmaとwebpackでの予約語「class」の使用

私はカルマテストランナーとカバレッジをistanbulで設定しようとしています。

私はカルマでユニットテストを出せしようとすると、私はエラーを以下ました:

Use of reserved word 'class' 

これは私のカルマの設定ファイルである:

var path = require('path'); 

module.exports = function (config) { 
    config.set({ 

     basePath: '', 

     plugins: [ 
      'karma-coverage', 
      'karma-jasmine', 
      'karma-phantomjs-launcher', 
      'karma-webpack', 
      'karma-coverage-istanbul-reporter' 
     ], 

     frameworks: ['jasmine'], 

     files: [ 
      'tests/index.js' 
     ], 

     preprocessors: { 
      'tests/index.js': 'webpack' 
     }, 

     webpack: { 
      module: { 
       rules: [{ 
        test : /\.js$/, 
        use : { 
         loader: 'istanbul-instrumenter-loader', 
         query : { 
          esModules: true 
         } 
        }, 
        include: path.resolve('src/') 
       }, { 
        test: /\.html$/, loaders: ["html-loader"] 
       }, { 
        test: /\.less$/, 
        use : [{ 
         loader: "style-loader" 
        }, { 
         loader: "css-loader" 
        }, { 
         loader: "less-loader" 
        }] 
       }, { 
        test : /\.woff($|\?)|\.woff2($|\?)|\.ttf($|\?)|\.eot($|\?)|\.svg($|\?)/, 
        loader: 'url-loader' 
       }] 
      } 
     }, 

     reporters: ['progress', 'coverage-istanbul'], 

     coverageIstanbulReporter: { 
      reports    : ['text-summary'], 
      fixWebpackSourcePaths: true 
     }, 

     port  : 9876, 
     colors  : true, 
     logLevel : config.LOG_INFO, 
     autoWatch : true, 
     browsers : ['PhantomJS'], 
     singleRun : true, 
     concurrency: Infinity, 
    }) 
}; 

そして、これが私のtests/index.jsファイル

です
// requires all tests in `project/test/src/components/**/index.js` 
const tests = require.context('./specs/', true, /index\.js$/); 
tests.keys().forEach(tests); 

// requires all components in `project/src/components/**/index.js` 
const components = require.context('../src/', true, /\.js$/); 
components.keys().forEach(components); 

私は何かを見逃しましたか?

ありがとうございました。

答えて

1

PhantomJSは現在es2015 +をサポートしていません。

babel-loaderのようなトランスバータローダー、 が必要な場合や、新しい構文をサポートするPhantomJSベータ版をインストールする必要がある場合。

関連する問題