使用karma instanbul覆盖率报告输出错误

时间:2017-02-16 18:38:45

标签: karma-runner istanbul

我正在尝试生成覆盖率报告,但我遇到了一个问题。我收到了Error: Unable to lookup source错误...

enter image description here

我不明白为什么要在文件名中查找?[hash],如果有办法删除它?

我的grunt-karma配置:

  var webpack = {
    module: {
      rules: [{
        test: /\.js$/,
        exclude: /node_modules|vue\/src|vue-router\//,
        loader: 'babel-loader',
        options: {
          presets: [
            ['es2015', { 'modules': false }]
          ],
          plugins: ['transform-runtime']
        }
      }, {
        test: /\.styl$/,
        loaders: ['style-loader', 'css-loader', 'stylus-loader']
      }, {
        test: /\.vue$/,
        loader: 'vue-loader',
        options: {
          postLoaders: {
            js: 'istanbul-instrumenter-loader?esModules=true'
          }
        }
      }, {
        include: /\.json$/,
        loaders: ['json-loader']
      }, {
        enforce: 'post',
        test: /\.js$/,
        exclude: /node_modules|vue\/src|vue-router\/|test\//,
        loader: 'istanbul-instrumenter-loader',
        query: {
          debug: true,
          preserveComments: true,
          esModules: true
        }
      }]
    },
    resolve: {
      modules: ['node_modules'],
      alias: {vue: 'vue/dist/vue.js'}
    }
  };

karma: {
  unit: {
    options: {
      frameworks: ['jasmine'],
      singleRun: true,
      colors: true,
      browsers: ['Chrome'],
      phantomjsLauncher: {
        exitOnResourceError: true
      },
      reporters: ['spec', 'coverage-istanbul'],
      files: [
        { pattern: 'test/unit/**/*-spec.js', watched: false }
      ],
      preprocessors: {
        'test/unit/**/*-spec.js': ['webpack']
      },
      webpack: {
        devtool: 'eval-source-map',
        module: webpack.module,
        resolve: webpack.resolve
      },
      webpackMiddleware: {
        noInfo: true,
        stats: 'errors-only'
      },
      coverageIstanbulReporter: {
        dir: './build/reports/unit',
        reports: [ 'text-summary', 'html' ],
        fixWebpackSourcePaths: true,
        'report-options': {
          html: {
            verbose: true,
            subdir: 'html'
          }
        }
      }
    },
    specReporter: {
      suppressSkipped: false
    }
  }
}

1 个答案:

答案 0 :(得分:0)

删除devtool: 'eval-source-map'