为什么我的业力不支持陈述?

时间:2016-12-02 09:33:00

标签: javascript reactjs ecmascript-6 karma-jasmine karma-mocha

我将业力设置为我的单元测试框架。但它不会编译下面的代码:

let {btnData} = this.props
let buttons = []
for (let btn of btnData) {
  btn = {...btnCategories[btn.type], ...btn}
  buttons.push(btn)
}

我在for循环线上得到了以下错误。为什么它不承认...的陈述?

Can't find variable: Symbol

下面是我的业力配置文件。我的项目包括webpack,reactjs,并使用业力,摩卡,柴,酶作为测试库。

var path = require('path')
module.exports = function(config) {
  config.set({
    basePath: '',
    frameworks: ['mocha', 'chai'],
    files: [
      '../test/**/*.js'
    ],

    preprocessors: {
      // add webpack as preprocessor
      '../src/**/*.js': ['webpack', 'sourcemap'],
      '../test/**/*.js': ['webpack', 'sourcemap'],
      '../src/**/*.less': ['webpack', 'sourcemap']
    },
    webpack: { //kind of a copy of your webpack config
      devtool: 'inline-source-map', //just do inline source maps instead of the default
      module: {
        loaders: [
          {
            test: /\.js$/,
            loader: 'babel',
            exclude: /node_modules/,
            query: {
              presets: ['airbnb']
            }
          },
          {
            test: /\.json$/,
            loader: 'json',
          },{
            test: /\.less$/,
            loader: "style!css!less",
          },
        ]
      },
      externals: {
        'react/lib/ExecutionEnvironment': true,
        'react/lib/ReactContext': true,
        'react/addons': true
      },
      resolve: {
        alias: {
          app: path.join(__dirname, '../src/js')
        }
      }
    },

    webpackServer: {
      noInfo: true //please don't spam the console when running in karma!
    },

    plugins: [
      'karma-webpack',
      'karma-jasmine',
      'karma-sourcemap-loader',
      'karma-chrome-launcher',
      'karma-phantomjs-launcher',
      'karma-mocha',
      'karma-chai',
      'karma-mocha-reporter'
    ],


    babelPreprocessor: {
      options: {
        presets: ['airbnb']
      }
    },
    reporters: ['mocha'],

    // reporter options
    mochaReporter: {
      colors: {
        success: 'blue',
        info: 'bgGreen',
        warning: 'cyan',
        error: 'red'
      },
      symbols: {
        success: '+',
        info: '#',
        warning: '!',
        error: 'x'
      }
    },
    port: 9876,
    colors: true,
    logLevel: config.LOG_INFO,
    autoWatch: true,
    browsers: ['Chrome'],
    singleRun: false,
  })
};

0 个答案:

没有答案