Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Extends QUnit's CLI support to many common CLI environments.

branch: master
README.md

QUnit Extras v1.0.0

Extends QUnit with extra features and CLI support.

Support

QUnit Extras has been tested in at least Node.js 0.6.21~0.10.26, Narwhal 0.3.2, PhantomJS 1.9.2, RingoJS 0.9, & Rhino 1.7RC5.

Usage

;(function() {

  // used as reference to the global object
  var root = typeof global == 'object' && global || this;

  // used as a no-op function
  var noop = Function.prototype;

  // use a single "load" function
  var load = (typeof require == 'function' && !(root.define && define.amd))
    ? require
    : (!root.document && root.java && root.load) || noop;

  // load QUnit in a way to workaround cross-environment issues
  var QUnit = (function() {
    return  root.QUnit || (
      root.addEventListener || (root.addEventListener = noop),
      root.setTimeout || (root.setTimeout = noop),
      root.QUnit = load('path/to/qunit.js') || root.QUnit,
      addEventListener === noop && delete root.addEventListener,
      root.QUnit
    );
  }());

  // load and install QUnit Extras
  var qe = load('path/to/qunit-extras.js');
  if (qe) {
    qe.runInContext(root);
  }

  // set the number of retries async tests make attempt
  QUnit.config.asyncRetries = 10;

  // excuse tests
  QUnit.config.excused = {
    // specify the module name
    'qunit module': {
      // excuse individual asserts in a test
      'a qunit test': [
        // excuse by assert message
        'assert message',

        // excuse by expected result
        '[1,2,3]',

        // excuse by error indicator
        'Died on test #1',
      ],
      // or excuse an entire test
      'another qunit test': true
    }
  };

  // call `QUnit.module()` instead of `module()` when in a CLI
  QUnit.module('some test module');

  test('some test', function() {
    // ...
  });

  // call `QUnit.start()` when in a CLI or PhantomJS
  if (!root.document || root.phantom) {
    QUnit.start();
  }
}.call(this));

Footnotes

  1. QUnit v1.3.0 and v1.12.0-v1.14.0 are not fully supported by QUnit Extras CLI additions
  2. Rhino v1.7RC4 does not support timeout fallbacks clearTimeout and setTimeout

Author

twitter/jdalton
John-David Dalton
Something went wrong with that request. Please try again.