Home

Awesome

browserify-test

Simplify testing of front-end libraries using browserify and mocha

Features:

Usage

Install with npm and make sure phantomjs is installed (phantomjs -v):

npm install --global browserify-test

Pass test files to browserify-test and enjoy browserified mocha tests:

browserify-test --help

  Usage: browserify-test [options] [./test/*.js ...]

  Options:

    -h, --help                  output usage information
    -V, --version               output the version number
    -w, --watch                 run watch server on http://localhost:7357
    -t, --transform <t1,t2,..>  add browserify transforms
    -p, --plugins <p1,p2,..>    add browserify plugins
    -b, --browserifyOptions <jsonStringifiedObj>     add browserifyOptions
    --testem, --testemOptions <jsonStringifiedObj>   add testemOptions

browserify-test # run tests for ./test/*.js
browserify-test --watch # start watch server on localhost:7537
browserify-test ./path/to/test.js ./path/to/another-test.js # pass test files as arguments
browserify-test ./lib/**/test.js # use globs
browserify-test --transform [ babelify --presets env ] ./path/to/es6-test.js # use transforms

Integration with npm

Add browserify-test to your development dependencies:

npm install --save-dev browserify-test

And use npm scripts to run your tests in terminal with npm test or start development watch server with npm start.

{
  "scripts": {
    "test": "browserify-test ./test/index.js",
    "start": "browserify-test --watch ./test/index.js"
  },
  "devDependencies": {
    "browserify-test": "^3.1.0"
  }
}

npm hint: you don't need to type ./node_modules/.bin/browserify-test to refer on local copy of browserify-test, npm does it automatically.

Node.js

import run from 'browserify-test'

run({
  watch: false,
  transform: ['brsf', ['babelify', { presets: 'env' }]],
  files: ['./test/file1.js', './test/file2.js'],
}) // Returns the underlying `browserify` instance

Options

License

MIT