Build tests with Webpack and run them with Mocha in one command
Support this project by ⭐️ starring and sharing it. Follow me to see what other cool projects I'm working on! ❤️
npm i -D mocha webpack instant-mocha
mocha are peer-dependencies so you can provide any version
instant-mocha --webpack-config <Webpack config path> [test paths/globs...]
Path to the Webpack config.
Watch mode. Re-compiles the Webpack build and re-run tests on file-changes.
For more info, run:
instant-mocha ---webpack-config webpack.config.js --require setup.js 'tests/*.spec.js'
setup.js. Note, this is not apart of the build and is loaded directly from Node.js
devtool: 'source-map' in your Webpack config.
Add webpackbar to your Webpack config.
They can't be automatically externalized because it's possible some dependencies require bundling or pre-processing. For example, packages in ESM format or deep-dependencies that are stubbed for testing.
First of all, major thanks to mocha-webpack for the original implementation and serving the community.
This project was created from scratch because
mocha-webpack is no longer maintained and doesn't have Webpack 5 support (and neither does its fork, mochapack).
Some notable improvements include:
mocha-webpackreturns the number of failed tests as the exit code. instant-mocha only uses exit code
1for any test failures as per Bash convention.
MIT © Hiroki Osame
Logo made by monkik