Git Product home page Git Product logo

aok's Introduction

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

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

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

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

Fund development with tips to @ryanve =)

License

MIT

aok's People

Contributors

ryanve avatar

Watchers

JT5D avatar James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.