1

I'm trying to generate istanbul coverage reports for my react components, using (webpack/karma). But the generated report shows the code after transpile and full of (necessary) code.

Coverage

Is there a way to view before transpiling JSX code in the report or at least only the real application code?

I am using a istanbul-instrumenter as a postLoader in my karma.conf.js:

webpack: {
    postLoaders: [ { 
        //delays coverage til after tests are run, fixing transpiled source coverage error
        test: /\.jsx$/,
        exclude: /(test|node_modules|bower_components)\//,
        loader: 'istanbul-instrumenter' }
    ]
}
4

1 回答 1

0

我只是通过从更改为istanbul-instrumenter-loader来解决它babel-istanbul-instrumenter-loader

遵循所需的配置:

 preLoaders: [
   // transpile and instrument only testing sources with babel-istanbul
   {
     test: /.jsx?$/,
     loader: 'babel-istanbul',
     include: [
       path.resolve(__dirname, "/src/"), // My tests are under src folder :(
     ],
     query: {
       cacheDirectory: true
     }
  }
]
于 2016-04-05T07:30:31.443 回答