Skip to content

Latest commit

 

History

History
69 lines (52 loc) · 2.04 KB

README.md

File metadata and controls

69 lines (52 loc) · 2.04 KB

Extensible JavaScript test suite module

API (1.7)

aok(testObject)

testObject properties

  • id: identifier or name for the test (defaults to a positive integer)
  • test: result or callback (called in testObject's scope)
  • pass: message or callback (default: "Pass")
  • 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

Syntax

Objects
aok({
    id: 'example'
  , test: function() {
        return 'example' === this.id;
    }
});
Shorthand
Non-objects become the .test
aok(typeof aok == 'function');
aok(aok instanceof aok);
aok(function() {
    return isFinite(this.id);
});

Console methods

  • aok.log(message)
  • aok.info(message)
  • aok.warn(message)
  • aok.error(message)
  • aok.assert(expression, message) 1.6+
  • aok.trace()
  • aok.clear() 1.7+

Utilities

  • aok.can(fn) Get a new function that uses try/catch to test if fn can run.
  • aok.explain(item?) Represent item (or self) as a string.
  • aok.perform(trials, fn) Test how many milliseconds it takes for fn to run trials times.
  • aok.race(trials, rivals) Test how many milliseconds it takes each rival to run trials times.
  • aok.pass(stack, test, scope?, limit?) Iterate stack to count passes until limit.
  • aok.fail(stack, test, scope?, limit?) Iterate stack to count fails until limit.
  • aok.result(object, key|fn) Get object[key] or its method's result if callable.

License: MIT

Copyright (C) 2013 by Ryan Van Etten