Karma Coverage (Jasmine, Babel, Webpack)

442 views Asked by At

After making changes to my karma.conf.js to allow for Karma Coverage, running karma now fails. I'm not really sure what is going on. Any thoughts?

process.env.NODE_ENV = 'test';

module.exports = function(config) {
    config.set({
    autoWatch: true,
    browsers: ['Chrome'], //, 'Firefox', 'Safari'],
    frameworks: ['jasmine'],
    logLevel: config.LOG_INFO,
    singleRun: false,
    port: 9876,
    colors: true,
    concurrency: Infinity, // how many browser should be started simultaneous
    files: [
        'test/**/*Spec.js',
        'src/**/*.js' //ADDED FOR COVERAGE
    ],
    preprocessors: {
        'test/**/*Spec.js' : ['babel', 'webpack', 'sourcemap'],
        'src/**/*.js' : ['babel', 'webpack', 'sourcemap', 'coverage'] //ADDED FOR COVERAGE

    },
    reporters: ['progress', 'coverage'], //ADDED FOR COVERAGE
    coverageReporter: { //ADDED FOR COVERAGE
        type : 'html',
        dir : 'coverage/'
    },
    webpack: {
        devtool: 'inline-source-map',
        resolve: {
            extensions: ['', '.js', '.jsx'],
            modulesDirectories: [
                'node_modules'
            ]
        },
        module: {
            loaders: [
                {
                    test: /\.(js|jsx)$/,
                    exclude: /(node_modules)/,
                    loader: 'babel-loader'
                },
                {
                    test: /\.css$/,
                    loader: "style-loader!css-loader"
                }
            ]
        },
        externals: {
            'cheerio': 'window',
            'react/addons': true,
            'react/lib/ExecutionEnvironment': true,
            'react/lib/ReactContext': true
        }
    },
    webpackServer: {
        noInfo: true //don't spam the console when running in karma!
    },

    plugins: [
        "karma-babel-preprocessor",
        "karma-chrome-launcher",
        "karma-webpack",
        "karma-sourcemap-loader",
        "karma-jasmine",
        'karma-coverage'  //ADDED FOR COVERAGE
    ],

    babelPreprocessor: {
        options: {
            presets: [
                "latest",
                "react-app"
            ],
            sourceMap: 'inline',
            plugins: [
                "transform-object-rest-spread"
            ]
        }
    }
})
}

I'm getting the following error (and many more similar below this)

27 12 2016 06:35:35.997:ERROR [karma]: { Error: no such file or directory at MemoryFileSystem.readFileSync (/Users/lancepoehler/Documents/workspaces/SolarAnalysisClient/node_modules/memory-fs/lib/MemoryFileSystem.js:114:10) at MemoryFileSystem.readFile (/Users/lancepoehler/Documents/workspaces/SolarAnalysisClient/node_modules/memory-fs/lib/MemoryFileSystem.js:297:21) at doRead (/Users/lancepoehler/Documents/workspaces/SolarAnalysisClient/node_modules/karma-webpack/lib/karma-webpack.js:201:29) at Plugin.readFile (/Users/lancepoehler/Documents/workspaces/SolarAnalysisClient/node_modules/karma-webpack/lib/karma-webpack.js:205:5) at _combinedTickCallback (internal/process/next_tick.js:67:7) at process._tickCallback (internal/process/next_tick.js:98:9) code: 'ENOENT', errno: 34, message: 'no such file or directory', path: '/_karma_webpack_/src/components/Error.js' }

0

There are 0 answers