codymikol / karma-webpack

Karma webpack Middleware
MIT License
830 stars 222 forks source link

WebpackOptionsValidationError and No provider for "framework:mocha" #300

Closed marcus-petty closed 6 years ago

marcus-petty commented 6 years ago

I'm submitting a bug report

Hi!

We get these errors when using these versions libs

Webpack version: "webpack": "^3.11.0", karma-webpack version: "karma-webpack": "^2.0.9", Karma version: "karma": "^2.0.0",

Error: No provider for "framework:mocha"! (Resolving: preprocess -> preprocessor:webpack -> framework:mocha)

20 02 2018 15:19:29.939:ERROR [preprocess]: Can not load "webpack"!
  WebpackOptionsValidationError: Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema.
 - configuration.entry should be one of these:
/*eslint-disable no-var*/

var webpackConfig = require('./webpack.config.js');
webpackConfig.entry = {};

module.exports = function(config) {
    config.set({
        basePath: '',
        frameworks: ['mocha', 'chai'],

        // list of files / patterns to load in the browser
        files: [
            'test/unit/**/*.spec.ts'
        ],

        // list of files to exclude
        exclude: [
        ],
        preprocessors: {
            'test/unit/**/*.ts': ['webpack']
        },
        reporters: ['progress'],
        port: 9876,
        // enable / disable colors in the output (reporters and logs)
        colors: true,

        logLevel: config.LOG_INFO,

        // enable / disable watching file and executing tests whenever any file changes
        autoWatch: true,

        browsers: ['Chrome'],
        singleRun: false,
        concurrency: Infinity,

        webpack: webpackConfig,

        webpackMiddleware: {
            noInfo: true
        }
    });
};

karma config:

/*eslint-disable no-var*/

var webpackConfig = require('./webpack.config.js');
webpackConfig.entry = {};

module.exports = function(config) {
    config.set({
        basePath: '',
        frameworks: ['mocha', 'chai'],

        // list of files / patterns to load in the browser
        files: [
            'test/unit/**/*.spec.ts'
        ],

        // list of files to exclude
        exclude: [
        ],
        preprocessors: {
            'test/unit/**/*.ts': ['webpack']
        },
        reporters: ['progress'],
        port: 9876,
        // enable / disable colors in the output (reporters and logs)
        colors: true,

        logLevel: config.LOG_INFO,

        // enable / disable watching file and executing tests whenever any file changes
        autoWatch: true,

        browsers: ['Chrome'],
        singleRun: false,
        concurrency: Infinity,

        webpack: webpackConfig,

        webpackMiddleware: {
            noInfo: true
        }
    });
};