i'm trying setup project webpack, babel , karma, i'm having problem configure test coverage of source files.
i'm using webpack bundle , transpile javascript files using babel-loader , karma karma-webpack run tests.
the problem can't include source files coverage, ones import on test files. i'm using babel-plugin-istanbul instrument es2015 code.
here webpack configuration file:
const { resolve } = require('path'); module.exports = { context: __dirname, entry: './main.js', output: { filename: 'bundle.js', path: resolve(__dirname, 'dist'), }, resolve: { root: __dirname, extensions: ['', '.js', '.jsx'], alias: { components: resolve(__dirname, 'src/components'), }, }, devtool: 'eval-source-map', module: { loaders: [ { test: /\.jsx?$/, loader: 'babel', exclude: /node_modules/, }, ], }, };
and karma configuration file:
const webpackconfig = require('./webpack.config'); process.env.babel_env = 'test'; module.exports = function karmaconfig(config) { config.set({ basepath: './', frameworks: ['mocha', 'chai', 'sinon'], files: ['specs/**/*.spec.js'], plugins: [ 'karma-webpack', 'karma-mocha', 'karma-chai', 'karma-sinon', 'karma-spec-reporter', 'karma-coverage', 'karma-spec-reporter', 'karma-phantomjs-launcher', ], preprocessors: { 'specs/**/*.spec.js': ['webpack'], 'src/**/*.+(js|jsx)': ['webpack'], }, reporters: ['spec', 'coverage'], coveragereporter: { dir: 'coverage', reporters: [ { type: 'lcov', subdir: 'reporter-lcov' }, { type: 'text-summary' }, ], }, webpack: webpackconfig, webpackmiddleware: { noinfo: true, }, port: 9876, colors: true, loglevel: config.log_info, autowatch: true, browsers: ['phantomjs'], singlerun: false, concurrency: infinity, }); };
and here's .babelrc
file, configure babel-plugin-istanbul:
{ "presets": ["es2015", "react"], "env": { "test": { "plugins": [ ["istanbul", { "exclude": ["**/*.spec.js"] }] ] } } }
am missing something?
thanks in advance!
Comments
Post a Comment