aok

Extensible test suite API.

aok

Extensible JavaScript test suite module

API (1.9)

  • id: identifier or name for the test (defaults to a positive integer)
  • test: result or callback (called in the instance's scope)
  • pass: message or callback (default: "ok")
  • fail: message or callback (default: "FAIL")
  • handler: defaults to aok.prototype.handler
  • express: defaults to aok.prototype.express
  • explain: defaults to aok.prototype.explain
  • run: defaults to aok.prototype.run
  • cull: defaults to aok.prototype.cull
  • init: defaults to aok.prototype.init
aok({
  id: 'example',
  testfunction() {
    return 'example' === this.id;
  }
});
aok(true);
aok(aok instanceof aok);
aok(function() {
  return isFinite(this.id);
});
aok(id, test) 1.8+
aok('example', true);
aok('example', function() {
  return true;
});
var o = aok();
o.test = true;
o.run();

uses native console where available

  • aok.log(message)
  • aok.info(message)
  • aok.warn(message)
  • aok.error(message)
  • aok.assert(expression, message) 1.6+
  • aok.trace()
  • aok.clear() 1.7+
  • Get a new function that uses try/catch to test if fn can run.
  • ⇒ Function (⇒ boolean)
  • Iterate stack to count passes until limit. (example)
  • ⇒ number
  • Iterate stack to count fails until limit. (example)
  • ⇒ number
  • Test how many milliseconds it takes fn to run trials times.
  • ⇒ number
  • Test how many milliseconds it takes each rival to run trials times.
  • ⇒ Array
  • Get object[key] or its method's result if callable.
  • ⇒ *
  • Represent item (or self) as a string.
  • ⇒ string

aok 1.5+ includes a simple grunt task for running tests via grunt

Configure files to require
grunt.initConfig({
  aok: {
    test: ['./test/'],
    extras: ['./test/extras'] 
  }
});
grunt.loadNpmTasks('aok');
$ grunt aok
$ grunt aok:test
$ grunt aok:extras

Contribute edits to /src or report issues

$ npm install       # install dependencies 
$ grunt jshint:sub  # lint sub dirs 
$ grunt aok         # run tests 

Builds have +timestamp in the version number and are made later via grunt.

Tip the developer =)

MIT