Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

zuul

Package Overview
Dependencies
Maintainers
1
Versions
93
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

zuul

browser testing harness for mocha tests

  • 0.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3.6K
increased by53.32%
Maintainers
1
Weekly downloads
 
Created
Source

zuul

Zuul is a test runner/harness to make running your mocha tests in a browser easier. Just point it at your mocha test files and let zuul consume them!

zuul server

If you want to see the output of your mocha tests in a pretty browser window use zuul with the server option.

$ zuul --server 9000 /path/to/your/tests

Zuul will start a server on localhost:9000 which you can visit to get awesome html output (courtesy of mocha).

html

headless zuul

If you just want to run your tests in a headless environment courtesy of mocha-phantomjs and phantomjs, zuul will oblige!

$ zuul /path/to/your/tests

headless

finding tests

You can specify either a specific javascript file(s) or a directory(s) to zuul. If you specify a directory, zuul will load all of the .js files in that directory.

mocha.opts

If test/mocha.opts is available relative to your launch directory, then zuul will incorporate those options into the mocha setup.

install

$ npm install -g zuul

usage

zuul [options] file(s)|dir

Options:
  --server   port to start harness server for manual testing
  --wwwroot  location where the webserver will serve additional static files
  --ui       mocha ui (bdd, tdd, qunit, exports
  --config   point to a config file that overrides zuul settings

config

Most likely zuul will serve your needs out of the box, but if you need to customize the browserify step, the test fixture and/or want to add extra endpoints to the zuul test server, the --config option is your friend.

Lets say we have a ./zuul-config.js file in our current directory, running zuul --config ./zuul-config.js picks up eventual overrides specified in it, all of which are optional:

  • browserify: {Function} that needs to return a browserify instance that can be initialized according to our needs
  • bundleOpts: {Object} options passed to browserify().bundle(options)
  • fixture: {Function} returning a {String} that allows overriding the default html fixture, but needs to keep the necessary setup (mocha, phantom) in order to work with zuul
  • initApp: {Function} invoked with the app instance and express which allows adding endpoints to the app and whatever else you need to do to properly set up your tests

Here is an example zuul-config.js:

var fs = require('fs');
var path = require('path');
var browserify = require('browserify');

// overriding the browserify instance creation in order to add a transform
exports.browserify = function () {
  return browserify().transform('brfs');

};

// at times we need to override browserify bundle options
exports.bundleOpts = { ignoreMissing: true, debug: true };

// we need to add a sinon.js script tag, so we'll use our custom fixture
exports.fixture = function () {
  return fs.readFileSync(path.join(testroot, 'fixture.html'), 'utf8');
};

exports.initApp = function (app, express) {
  var sinonpkg = path.join(path.dirname(require.resolve('sinon')), '..', 'pkg', 'sinon.js');

  // log requests made to the zuul test server
  app.use(express.logger('dev'));

  // provide the sinon file that we request via a script tag in our custom fixture
  app.get('/sinon.js', function (req, res) {
    res.sendfile(sinonpkg);
  });
};

credits

This probject is just a tiny tool. The real credit goes to these projects.

Keywords

FAQs

Package last updated on 04 Aug 2013

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc