karma-runner / karma-runner/karma
ERROR [preprocess]: Can not load "webpack"! WebpackOptionValidationError
- Dominant language
- JavaScript
- Stars
- 12k
- Forks
- 1.7k
- PR merge metrics
- No merged PRs in 30d
Description
### Plugins
- Karma v1.3.0
- Karma-webpack v2.0.2
- Webpack v2.2.1
### Karma.config.js
var argv = require('yargs').argv;
var path = require('path');
module.exports = function (config) {
config.set({
browsers: ['Chrome'],
singleRun: !argv.watch,
frameworks: ['chai', 'mocha'],
reporters: ['mocha', 'coverage'],
mochaReporter: {
output: 'autowatch'
},
coverageReporter: {
reporters: [
{ type: 'html', dir: './coverage' },
{ type: 'text-summary' }
]
},
files: [
'./node_modules/babel-polyfill/dist/polyfill.js',
{
pattern: `./test_bundler.js`,
watched: false,
served: true,
included: true
}
],
preprocessors: {
['./test_bundler.js']: ['webpack'],
// ['./test_bundler.js']: ['webpack', 'sourcemap'] - sourcemaps are cool but really slow.
// refer to sourcemaps built by "$ npm run build:dev" instead
},
port: 9876,
webpack: {
devtool: 'inline-source-map',
resolve: {
root: path.resolve(__dirname, './src'),
extensions: ['', '.js', '.jsx', '.json'],
alias: {
sinon: require.resolve('sinon/pkg/sinon')
}
},
module: {
noParse: [
/node_modules\/sinon\//
],
preLoaders: [{
test: /\.js?$/,
exclude: /(test|node_modules|bower_components)\//,
loader: 'isparta-instrumenter-loader'
}],
loaders: [
{
test: /\.jsx?$/,
exclude: /node_modules/,
loader: 'babel'
},
{
test: /\.json$/,
loader: 'json'
},
{
test: /\.woff2?$|\.ttf$|\.eot$|\.svg$/,
loader: 'file'
},
{
test: /\.scss$/,
loader: 'style!css!sass'
},
{
test: /\.css$/,
loader: 'style!css'
}
]
},
externals: {
'jsdom': 'window',
'react/addons': true,
'react/lib/ExecutionEnvironment': true,
'react/lib/ReactContext': 'window'
},
},
webpackMiddleware: {
noInfo: true,
stats: {
chunks: false
}
},
plugins: [
'karma-mocha',
'karma-chai',
'karma-webpack',
'karma-chrome-launcher',
'karma-mocha-reporter',
'karma-coverage'
//'karma-sourcemap-loader'
]
});
};
### Actual behaviour

Contributor guide
Research direction
Start with the Karma.config.js configuration and the referenced test_bundler.js entry point, then reproduce the preprocessing failure using the listed Karma, karma-webpack, and webpack versions. Compare the reported WebpackOptionValidationError with the webpack configuration shown; done means the test bundle loads without the preprocessing error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, webpack
- Domain
- build-system, testing-qa
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100