A CLI tool that integrates Mocha test runner with Webpack bundling, allowing you to test modules that rely on Webpack features (loaders, plugins, resolve aliases) without pre-building or using hacks. Version 1.1.0 is the latest stable release (as of late 2018). It supports Mocha >=2.4.5 <=5 and Webpack 2.x/3.x. Key differentiators: bundling tests into a single bundle with Webpack's full pipeline (loaders, resolve, plugins), built-in source map support, memory-fs for speed (no disk writes), customizable file watcher, and support for multiple entry files/patterns. The project is effectively unmaintained (last release 2017) for Webpack 4+ compatibility.
npm install mocha-webpackVerified import paths — ran on the pinned version, not inferred.
Configures mocha-webpack with a webpack config file, custom opts file, and runs tests matching a glob pattern.
Migrate to mochapack (https://github.com/sysgears/mochapack) or configure webpack+mocha manually.
Remove any references to generated bundle file. Use --webpack-config to specify output settings or rely on memory-fs.
Ensure webpack resolve.extensions includes '.js' and other extensions used in your tests.
Omit `entry` and `output` from your webpack test config, or use `--webpack-config` that merges partial configs.
Use webpack@3.x or switch to mochapack (supports webpack 4+).
Rename your opts file to `mocha-webpack.opts` or use `--opts path/to/your.opts`.
Install mocha-webpack locally: `npm install --save-dev mocha-webpack` and use npx or package.json scripts.
Downgrade to webpack@3 or migrate to mochapack.
Update to mocha-webpack@1.1.0 which fixed this bug.
Set webpack target to 'node' in your webpack config: `target: 'node'`.