karma-webpack-tape:测试失败时显示行号

时间:2016-05-23 19:31:56

标签: webpack karma-runner tap karma-webpack isparta

正如标题所暗示的那样,我希望能够在套件中测试失败时看到行号。我依赖于karma-tap插件,tap框架和dots记者。

一些上下文:源映射正常工作,因此测试文件中抛出的异常会报告正确的行以及堆栈跟踪。但是,当基本测试失败时,"失败"输出消息时没有关于线路或模块的任何信息。

Chrome 50.0.2661 (Mac OS X 10.11.4)  should be equal FAILED
    {
      "operator": "equal",
      "expected": 0,
      "actual": 1
    }
Chrome 50.0.2661 (Mac OS X 10.11.4)  should be equal FAILED
    {
      "operator": "equal",
      "expected": 0,
      "actual": 1
    }
................................................................................
................................................................................
................................................................................
................................................................................
................................................................................
...........................

我最初的想法是,这只是Tap的限制,但我无法想象这是真的。我的完整Karma配置如下所示。配置中是否存在导致测试期间行号输出失败的内容?

{
    plugins: [
      require('karma-webpack'),
      require('karma-tap'),
      require('karma-chrome-launcher'),
      require('karma-sourcemap-loader')
    ],

    basePath: '',
    frameworks: [ 'tap' ],
    files: [
      'tests.bootstrap.js',
    ],
    preprocessors: {
      'src/**/*.js': ['webpack', 'sourcemap'],
      'tests.bootstrap.js': [ 'webpack', 'sourcemap' ]
    },
    webpack: {
      devtool: 'inline-source-map',
      externals: {
       cheerio: 'window',
       'react/lib/ExecutionEnvironment': true,
       'react/lib/ReactContext': true,
       'text-encoding': 'window',
       'react/addons': true,
      },
      module: {
        preLoaders: [
          {
            test: /\.js/,
            exclude: /node_modules/,
            loader: 'babel'
          },
          {
            test: /\.js$/,
            include: [
              path.resolve(__dirname, 'src/components/'),
              //path.resolve(__dirname, 'src/containers/'),
              path.resolve(__dirname, 'src/layouts/'),
              path.resolve(__dirname, 'src/reducers/'),
              path.resolve(__dirname, 'src/stores/'),
              path.resolve(__dirname, 'src/util/')
            ],
            exclude: /-container\.js/,
            loader: 'isparta'
          }
        ],
        loaders: [
          {
            test: /\.js$/,
            exclude: /node_modules/,
            loader: "source-map-loader"
          }, {
            test: /\.(png|jpg|jpeg|gif|woff|woff2)$/,
            loader: 'url?limit=25000',
            include: path.resolve(__dirname, 'src')
          }, {
            test: /\.svg$/,
            loader: 'file-loader'
          }
        ]
      },
      node : {
        fs: 'empty'
      },
      resolve: {
        modulesDirectories: ['src', 'node_modules']
      }
    },

    webpackMiddleware: {
      noInfo: true
    },

    reporters: [ 'dots' ],

    client: {
      captureConsole: false
    },

    port: 9878,
    colors: true,
    logLevel: config.LOG_DEBUG,
    autoWatch: true,
    browsers: ['Chrome'],
    singleRun: false
  }

0 个答案:

没有答案