Skip to content
forked from rtsao/unitest

🌎 Seamless node and browser unit testing with code coverage

License

Notifications You must be signed in to change notification settings

cain-wang/unitest

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

95 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

unitest logo

build status dependencies status npm version

Seamless node and browser unit testing with code coverage

Features
  • 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

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

Getting Started

Run node and browser tests

  1. Transpile source code with Babel (optional)
  2. Bundle browser code (this step is possibly optional since require works in electron)
  3. 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

Run node and browser tests with coverage report

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

Merged test output

The separate TAP and coverage output along with exit code for your node and browser tests will be merged seamlessly.

Debugging

Debug node tests

No magic here, just use node-inspector or plain node.

npm install node-inspector -g
node-debug build/test/node.js

Debug browser (electron) tests

No magic here, just use devtool.

npm install devtool -g
devtool build/test/browser-bundle.js

About

🌎 Seamless node and browser unit testing with code coverage

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 98.5%
  • HTML 1.5%