mocha test runner with integrated webpack precompiler
mocha-webpack is basically a wrapper around the following command...
$ webpack test.js output.js && mocha output.js
... but in a much more powerful & optimized way.
Benefits over plain mocha
Unlike mocha, mocha-webpack analyzes your dependency graph and run only those test files that were affected by this file change.
You'll get continuous feedback whenever you make changes as all tests that are related in any way to this change will be tested again. Isn't that awesome?
If any build errors happens, they will be shown like below
mocha-webpack works with
Install mocha-webpack via npm install
$ npm install webpack mocha mocha-webpack --save-dev
and use it via npm scripts in your
Further installation and configuration instructions can be found in the installation chapter.
run a single test
run all tests by glob
Note: You may noticed the quotes around the glob pattern. That's unfortunately necessary as most terminals will resolve globs automatically.
run all tests in directory "test" matching the file pattern *.test.js (add
--recursive to include subdirectories)
mocha-webpack --glob "*.test.js" test
Watch mode? just add
mocha-webpack --watch test