1.9.0 • Published 10 years ago
aok v1.9.0
aok
Extensible JavaScript test suite module
API (1.9)
aok() → aok
instance
Syntaxes
Properties
- 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
Verbose syntax
aok(object)
aok({
id: 'example',
test: function() {
return 'example' === this.id;
}
});
Anonymous syntax
aok(test)
for non-object tests
aok(true);
aok(aok instanceof aok);
aok(function() {
return isFinite(this.id);
});
Pair syntax
aok(id, test)
1.8+
aok('example', true);
aok('example', function() {
return true;
});
Idle syntax
Calling aok()
without arguments creates an idle instance that can manually be run later.
var o = aok();
o.test = true;
o.run();
Console methods
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+
Utilities
aok.can(fn)
- Get a new function that uses
try
/catch
to test if fn can run. - ⇒ Function (⇒ boolean)
aok.pass(stack, fn, scope?, limit?)
- Iterate stack to count passes until limit. (example)
- ⇒ number
aok.fail(stack, fn, scope?, limit?)
- Iterate stack to count fails until limit. (example)
- ⇒ number
aok.perform(trials, fn)
- Test how many milliseconds it takes fn to run trials times.
- ⇒ number
aok.race(trials, rivals)
- Test how many milliseconds it takes each rival to run trials times.
- ⇒ Array
aok.result(object, key|fn)
- Get
object[key]
or its method's result if callable. - ⇒ *
aok.explain(item?)
- Represent item (or self) as a string.
- ⇒ string
grunt aok
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']
}
});
Load task 'aok'
grunt.loadNpmTasks('aok');
Run 'aok'
tasks
$ grunt aok
$ grunt aok:test
$ grunt aok:extras
Resources
- See a universal GruntFile and test dir for a solid setup
- See test dirs in ryanve packages for examples
Developers
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
.
Fund
License
1.9.0
10 years ago
1.8.1
10 years ago
1.8.0
10 years ago
1.7.3
10 years ago
1.7.2
10 years ago
1.7.1
11 years ago
1.7.0
11 years ago
1.6.1
11 years ago
1.6.0
11 years ago
1.5.3
11 years ago
1.5.2
11 years ago
1.5.1
11 years ago
1.5.0
11 years ago
1.4.0
11 years ago
1.3.0
11 years ago
1.2.2
11 years ago
1.2.1
11 years ago
1.2.0
11 years ago
1.1.0
11 years ago
1.0.0
11 years ago
0.9.0
11 years ago
0.8.1
11 years ago
0.8.0
11 years ago
0.7.1
11 years ago
0.7.0
11 years ago
0.6.2
11 years ago
0.6.0
11 years ago
0.5.0
11 years ago