Karma plugin that uses webpack to preprocess test files. Current stable version is 5.0.1, released February 2024, with a release cadence of roughly major versions every 1-2 years. It provides both a Karma framework and preprocessor, bundling test files and dependencies into shared bundles and chunks via webpack 5. Key differentiators: seamless integration of webpack with Karma's test runner, automatic handling of multiple outputs, and support for TypeScript out of the box. Requires webpack ^5.0.0 as a peer dependency and Node >=18.
npm install karma-webpackVerified import paths — ran on the pinned version, not inferred.
Configures Karma to use webpack as both framework and preprocessor for test files with a basic webpack setup.
Upgrade Node.js to version 18 or higher
Update webpack to ^5.0.0
Use webpack's built-in watch mode via Karma's autoWatch instead
Set { pattern: 'test/**/*.test.js', watched: false } in karma files configRemove entry from webpack config; let karma-webpack handle it
Add 'karma-webpack' to the plugins list: plugins: ['karma-webpack', ...]
Run npm install webpack@^5.0.0 --save-dev
Provide webpackMiddleware config: webpackMiddleware: { noInfo: true } or similarUpdate webpack config to be webpack 5 compatible (e.g., use optimization.splitChunks correctly)