Seamless node and browser unit testing with code coverage
- Unified node and browser tests with merged TAP output, code coverage reports, and exit status codes.
- Electron-powered browser testing for a fast, modern browser testing environment.
- Bundler-agnostic usage. Use browserify, webpack, or something else.
- Designed to be used with Babel-powered coverage instrumentation for fast, efficient testing with code coverage.
- Support for all coverage reporting options in Istanbul, including
html
,text
,cobertura
, etc.
Usage: unitest {OPTIONS}
Options:
--version, -v Print version and exit
--help, -h Print usage information
--node, -n Path to node test entry file
--browser, -c Path to browser test entry file
--report, -r Istanbul coverage report
- Transpile source code with Babel (optional)
- Bundle browser code (this step is possibly optional since
require
works in electron) - Run
unitest
, specifying test entry files
babel src -d build
browserify build/test/browser.js > build/test/browser-bundle.js
unitest --browser=build/test/browser-bundle.js --node=build/test/node.js
Running tests with coverage involves the exact same steps, but with an additional coverage instrumentation Babel plugin.
babel src -d build --plugins=istanbul
browserify build/test/browser.js > build/test/browser-bundle.js
unitest --browser=build/test/browser.js --node=build/test/node.js --report=html
The separate TAP and coverage output along with exit code for your node and browser tests will be merged seamlessly.
No magic here, just use node-inspector
or plain node.
npm install node-inspector -g
node-debug build/test/node.js
No magic here, just use devtool
.
npm install devtool -g
devtool build/test/browser-bundle.js