karma-webpack-with-fast-source-maps

raw JSON →
1.10.2 verified Sat Apr 25 auth: no javascript maintenance

A fork of karma-webpack that adds support for file-based source maps and hot testing. Version 1.10.2 supports webpack 1-3. It allows running only affected tests on file changes using a manifest array, and provides faster source map generation via 'cheap-module-source-map' devtool. This package is largely superseded by modern karma-webpack versions (5+) that include better source map support and webpack 5 compatibility. It is not actively maintained and should not be used for new projects.

error Module not found: Error: Can't resolve 'karma-webpack-with-fast-source-maps'
cause Package not installed or misspelled in npm install.
fix
Run: npm install --save-dev karma-webpack-with-fast-source-maps
error Error: Cannot find module 'webpack'
cause Missing peer dependency webpack.
fix
Run: npm install --save-dev webpack@3 (or compatible version)
error TypeError: Cannot read property 'webpack' of undefined
cause Missing webpack configuration in Karma config.
fix
Add webpack: { ... } to karma.conf.js
error Error: 'preprocessors' should be an object
cause Misplaced preprocessors or incorrect format in karma.conf.js
fix
Ensure preprocessors is a top-level config key with object value: preprocessors: { 'test.js': ['webpack'] }
deprecated Package is deprecated; use karma-webpack v5+ for webpack 4/5 support.
fix Replace with 'karma-webpack' and update configuration for version 5.
breaking Incompatible with webpack 4 and 5. Only supports webpack 1-3.
fix Upgrade to karma-webpack v4+ for webpack 4 support, or v5+ for webpack 5.
gotcha Preprocessor name is 'webpack' not the package name.
fix Use 'webpack' as preprocessor name, e.g., preprocessors: { 'test.js': ['webpack'] }.
gotcha The __karmaWebpackManifest__ variable is required in test entry file for selective test running; missing it may cause unexpected behavior.
fix Ensure test entry file declares var __karmaWebpackManifest__ = []; before using it.
breaking No support for ES modules (ESM) natively; requires Babel or other transpilation.
fix Add babel-loader or similar to webpack config to transpile ES modules.
npm install karma-webpack-with-fast-source-maps
yarn add karma-webpack-with-fast-source-maps
pnpm add karma-webpack-with-fast-source-maps

Karma configuration using karma-webpack-with-fast-source-maps with webpack preprocessor, fast source maps, and a single test entry point.

// karma.conf.js
module.exports = function(config) {
  config.set({
    browsers: ['ChromeHeadless'],
    frameworks: ['jasmine'],
    files: ['test/test_index.js'],
    preprocessors: {
      'test/test_index.js': ['webpack']
    },
    webpack: {
      devtool: 'cheap-module-source-map',
      module: {
        rules: [
          { test: /\.js$/, exclude: /node_modules/, use: 'babel-loader' }
        ]
      }
    },
    webpackMiddleware: { noInfo: true },
    singleRun: true
  });
};